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

Commit ca53f60

Browse files
committed
Improve double update checks for store
1 parent 3e0b332 commit ca53f60

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/createTests.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,31 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
516516
storeUnsubscribe()
517517
})
518518

519-
it('only triggers once when updating path via history push', () => {
519+
it('only triggers history once when updating path via history push', () => {
520520
const updates = []
521521
const historyUnsubscribe = history.listen(location => {
522522
updates.push(location.pathname);
523523
})
524524

525525
history.pushState(null, '/bar')
526-
expect(updates).toEqual(['/', '/bar'])
526+
history.pushState(null, '/baz')
527+
expect(updates).toEqual(['/', '/bar', '/baz'])
527528

528529
historyUnsubscribe()
529530
})
531+
532+
it('only triggers store once when updating path via history push', () => {
533+
const updates = []
534+
const storeUnsubscribe = store.subscribe(() => {
535+
updates.push(store.getState().routing.path);
536+
})
537+
538+
history.pushState(null, '/bar')
539+
history.pushState(null, '/baz')
540+
expect(updates).toEqual(['/bar', '/baz'])
541+
542+
storeUnsubscribe()
543+
})
530544
})
531545

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

0 commit comments

Comments
 (0)