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

Commit fe989a8

Browse files
committed
Add test checking number of store updates
1 parent d19add3 commit fe989a8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/createTests.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
489489
).toNotThrow()
490490
})
491491

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

502502
historyUnsubscribe()
503503
})
504+
505+
it('only triggers store once when updating path via store', () => {
506+
const updates = []
507+
const storeUnsubscribe = store.subscribe(() => {
508+
updates.push(store.getState().routing.path);
509+
})
510+
511+
store.dispatch(pushPath('/bar'));
512+
store.dispatch(pushPath('/baz'));
513+
store.dispatch(replacePath('/foo'));
514+
expect(updates).toEqual(['/bar', '/baz', '/foo'])
515+
516+
storeUnsubscribe()
517+
})
504518
})
505519

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

0 commit comments

Comments
 (0)