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

Commit

Permalink
Improve tests for double updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjoar committed Dec 10, 2015
1 parent 966829b commit b1a16c1
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions test/createTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,33 +604,25 @@ module.exports = function createTests(createHistory, name, reset = defaultReset)
})

it('only triggers once when updating path via store', () => {
let count = 0
const updates = []
const historyUnsubscribe = history.listen(location => {
// excluding the inital url
if (location.pathname !== '/') {
count++
}
updates.push(location.pathname);
})

store.dispatch(pushPath('/bar'));

expect(count).toEqual(1)
expect(updates).toEqual(['/', '/bar'])

historyUnsubscribe()
})

it('only triggers once when updating path via history push', () => {
let count = 0
const updates = []
const historyUnsubscribe = history.listen(location => {
// excluding the inital url
if (location.pathname !== '/') {
count++
}
updates.push(location.pathname);
})

history.pushState(null, '/bar')

expect(count).toEqual(1)
expect(updates).toEqual(['/', '/bar'])

historyUnsubscribe()
})
Expand Down

0 comments on commit b1a16c1

Please sign in to comment.