diff --git a/test/ConnectedRouter.test.js b/test/ConnectedRouter.test.js
index a2dabd8d..af05a0b5 100644
--- a/test/ConnectedRouter.test.js
+++ b/test/ConnectedRouter.test.js
@@ -178,7 +178,7 @@ describe('ConnectedRouter', () => {
history.push('/new-location')
expect(renderCount).toBe(2)
})
- })
+ })
describe('with immutable structure', () => {
let ConnectedRouter
@@ -243,6 +243,62 @@ describe('ConnectedRouter', () => {
expect(onLocationChangedSpy.mock.calls).toHaveLength(3)
})
+
+ it('only renders one time when mounted', () => {
+ let renderCount = 0
+
+ const RenderCounter = () => {
+ renderCount++
+ return null
+ }
+
+ mount(
+
+
+
+
+
+ )
+
+ expect(renderCount).toBe(1)
+ })
+
+ it('does not render again when non-related action is fired', () => {
+ // Initialize the render counter variable
+ let renderCount = 0
+
+ // Create redux store with router state
+ store = createStore(
+ combineReducers({
+ incrementReducer: (state = 0, action = {}) => {
+ if (action.type === 'testAction')
+ return ++state
+
+ return state
+ },
+ router: connectRouter(history)
+ }),
+ compose(applyMiddleware(routerMiddleware(history)))
+ )
+
+
+ const RenderCounter = () => {
+ renderCount++
+ return null
+ }
+
+ mount(
+
+
+
+
+
+ )
+
+ store.dispatch({ type: 'testAction' })
+ history.push('/new-location')
+ expect(renderCount).toBe(2)
+ })
})
describe('with seamless immutable structure', () => {
@@ -290,6 +346,62 @@ describe('ConnectedRouter', () => {
expect(onLocationChangedSpy.mock.calls).toHaveLength(2)
})
+
+ it('only renders one time when mounted', () => {
+ let renderCount = 0
+
+ const RenderCounter = () => {
+ renderCount++
+ return null
+ }
+
+ mount(
+
+
+
+
+
+ )
+
+ expect(renderCount).toBe(1)
+ })
+
+ it('does not render again when non-related action is fired', () => {
+ // Initialize the render counter variable
+ let renderCount = 0
+
+ // Create redux store with router state
+ store = createStore(
+ combineReducers({
+ incrementReducer: (state = 0, action = {}) => {
+ if (action.type === 'testAction')
+ return ++state
+
+ return state
+ },
+ router: connectRouter(history)
+ }),
+ compose(applyMiddleware(routerMiddleware(history)))
+ )
+
+
+ const RenderCounter = () => {
+ renderCount++
+ return null
+ }
+
+ mount(
+
+
+
+
+
+ )
+
+ store.dispatch({ type: 'testAction' })
+ history.push('/new-location')
+ expect(renderCount).toBe(2)
+ })
})
describe('Redux DevTools', () => {