Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dr3 committed Mar 9, 2020
1 parent dbb87d0 commit a78a799
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ConnectedRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const createConnectedRouter = (structure) => {
// Dispatch a location change action for the initial location.
// This makes it backward-compatible with react-router-redux.
// But, we add `isFirstRendering` to `true` to prevent double-rendering.
if(!props.noInitialPop) {
if (!props.noInitialPop) {
handleLocationChange(history.location, history.action, true)
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/ConnectedRouter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ describe('ConnectedRouter', () => {
history.push('/new-location')
expect(renderCount).toBe(2)
})

it('does not call `props.onLocationChanged()` on intial location when `noInitialPop` prop is passed ', () => {
mount(
<Provider store={store}>
<ConnectedRouter {...props} noInitialPop>
<Route path="/" render={() => <div>Home</div>} />
</ConnectedRouter>
</Provider>
)

expect(onLocationChangedSpy.mock.calls).toHaveLength(0)
})
})

describe('with immutable structure', () => {
Expand Down

0 comments on commit a78a799

Please sign in to comment.