From 7252178203a0acb9817d3f99746e76da8fad458f Mon Sep 17 00:00:00 2001 From: Kim Joar Bekkelund Date: Fri, 11 Dec 2015 20:09:14 +0100 Subject: [PATCH] Improve double update checks for store --- test/createTests.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/createTests.js b/test/createTests.js index fe8f094..add6f09 100644 --- a/test/createTests.js +++ b/test/createTests.js @@ -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', () => {