Skip to content

Commit 036fced

Browse files
committed
test: add assertion for initial redirection
1 parent ddc29ac commit 036fced

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Diff for: test/unit/specs/error-handling.spec.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ describe('error handling', () => {
5858
router.push('/foo').catch(err => {
5959
expect(err.type).toBe(NavigationFailureType.duplicated)
6060
expect(VueRouter.isNavigationFailure(err)).toBe(true)
61-
expect(VueRouter.isNavigationFailure(err, NavigationFailureType.duplicated)).toBe(true)
61+
expect(
62+
VueRouter.isNavigationFailure(err, NavigationFailureType.duplicated)
63+
).toBe(true)
6264
done()
6365
})
6466
})
@@ -156,7 +158,10 @@ describe('error handling', () => {
156158
// https://github.com/vuejs/vue-router/issues/3225
157159
it('should trigger onReady onSuccess when redirecting', done => {
158160
const router = new VueRouter({
159-
routes: [{ path: '/', component: {}}, { path: '/foo', component: {}}]
161+
routes: [
162+
{ path: '/', component: {}},
163+
{ path: '/foo', component: {}}
164+
]
160165
})
161166

162167
const onError = jasmine.createSpy('onError')
@@ -177,6 +182,7 @@ describe('error handling', () => {
177182
.push('/')
178183
.catch(pushCatch)
179184
.finally(() => {
185+
expect(router.currentRoute.path).toBe('/foo')
180186
expect(onReadyFail).not.toHaveBeenCalled()
181187
// in 3.2.0 it was called with undefined
182188
// expect(pushCatch).not.toHaveBeenCalled()
@@ -188,12 +194,14 @@ describe('error handling', () => {
188194

189195
it('should trigger onError if error is thrown inside redirect option', done => {
190196
const error = new Error('foo')
191-
const config = [{
192-
path: '/oldpath/:part',
193-
redirect: (to) => {
194-
throw error
197+
const config = [
198+
{
199+
path: '/oldpath/:part',
200+
redirect: to => {
201+
throw error
202+
}
195203
}
196-
}]
204+
]
197205

198206
const router = new VueRouter({
199207
routes: config

0 commit comments

Comments
 (0)