forked from remix-run/history
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always call listenBefore hooks on browser navigation
Fixes remix-run#71
- Loading branch information
Showing
6 changed files
with
149 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*eslint-env mocha */ | ||
|
||
function describePopState(createHistory) { | ||
describe('when a listenBefore hook is added', function () { | ||
let history, unlisten | ||
|
||
beforeEach(function () { | ||
history = createHistory() | ||
history.pushState(null, '/home') | ||
}) | ||
|
||
afterEach(function () { | ||
if (unlisten) | ||
unlisten() | ||
}) | ||
|
||
it('is called when browser navigation is used', function (done) { | ||
unlisten = history.listenBefore(function () { | ||
done() | ||
}) | ||
|
||
window.history.back() | ||
}) | ||
}) | ||
|
||
describe('when a deprecated transition hook is added', function () { | ||
let history, listener | ||
|
||
beforeEach(function () { | ||
history = createHistory() | ||
history.pushState(null, '/home') | ||
}) | ||
|
||
afterEach(function () { | ||
history.unregisterTransitionHook(listener) | ||
}) | ||
|
||
it('is called when browser navigation is used', function (done) { | ||
listener = function () { | ||
done() | ||
} | ||
|
||
history.registerTransitionHook(listener) | ||
|
||
window.history.back() | ||
}) | ||
}) | ||
} | ||
|
||
export default describePopState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters