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

Commit

Permalink
Improve double update checks for store
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjoar committed Dec 11, 2015
1 parent b1a16c1 commit 7252178
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/createTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,17 +615,31 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
historyUnsubscribe()
})

it('only triggers once when updating path via history push', () => {
it('only triggers history once when updating path via history push', () => {
const updates = []
const historyUnsubscribe = history.listen(location => {
updates.push(location.pathname);
})

history.pushState(null, '/bar')
expect(updates).toEqual(['/', '/bar'])
history.pushState(null, '/baz')
expect(updates).toEqual(['/', '/bar', '/baz'])

historyUnsubscribe()
})

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

history.pushState(null, '/bar')
history.pushState(null, '/baz')
expect(updates).toEqual(['/bar', '/baz'])

storeUnsubscribe()
})
})

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

0 comments on commit 7252178

Please sign in to comment.