-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(abstract): call afterHooks with go
Fix #3250
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Vue from 'vue' | ||
import VueRouter from '../../../src/index' | ||
|
||
Vue.use(VueRouter) | ||
|
||
const delay = t => new Promise(resolve => setTimeout(resolve, t)) | ||
|
||
describe('abstract history', () => { | ||
it('run afterEach after initial navigation', done => { | ||
const router = new VueRouter({ mode: 'abstract' }) | ||
const afterEach = jasmine.createSpy('afterEach') | ||
const onReady = jasmine.createSpy('ready') | ||
const onError = jasmine.createSpy('error') | ||
router.afterEach(afterEach) | ||
router.onReady(onReady, onError) | ||
|
||
router.push('/').finally(() => { | ||
expect(onReady).toHaveBeenCalled() | ||
expect(onError).not.toHaveBeenCalled() | ||
expect(afterEach).toHaveBeenCalled() | ||
done() | ||
}) | ||
}) | ||
|
||
it('run afterEach after router.go', done => { | ||
const router = new VueRouter({ mode: 'abstract' }) | ||
const afterEach = jasmine.createSpy('afterEach') | ||
|
||
router | ||
.push('/') | ||
.then(() => router.push('/foo')) | ||
.then(() => { | ||
router.afterEach(afterEach) | ||
router.go(-1) | ||
return delay(30) | ||
}) | ||
.finally(() => { | ||
expect(afterEach).toHaveBeenCalled() | ||
done() | ||
}) | ||
}) | ||
}) |