Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
Add test checking number of store updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjoar committed Dec 11, 2015
1 parent d19add3 commit fe989a8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/createTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
).toNotThrow()
})

it('only triggers once when updating path via store', () => {
it('only triggers history once when updating path via store', () => {
const updates = []
const historyUnsubscribe = history.listen(location => {
updates.push(location.pathname);
Expand All @@ -501,6 +501,20 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)

historyUnsubscribe()
})

it('only triggers store once when updating path via store', () => {
const updates = []
const storeUnsubscribe = store.subscribe(() => {
updates.push(store.getState().routing.path);
})

store.dispatch(pushPath('/bar'));
store.dispatch(pushPath('/baz'));
store.dispatch(replacePath('/foo'));
expect(updates).toEqual(['/bar', '/baz', '/foo'])

storeUnsubscribe()
})
})

it('handles basename history option', () => {
Expand Down

0 comments on commit fe989a8

Please sign in to comment.