@@ -9,7 +9,7 @@ describe('error handling', () => {
9
9
const router = new VueRouter ( )
10
10
const err = new Error ( 'foo' )
11
11
router . beforeEach ( ( ) => { throw err } )
12
- router . onError ( ( ) => { } )
12
+ router . onError ( ( ) => { } )
13
13
14
14
const onReady = jasmine . createSpy ( 'ready' )
15
15
const onError = jasmine . createSpy ( 'error' )
@@ -65,6 +65,26 @@ describe('error handling', () => {
65
65
router . push ( '/' )
66
66
} )
67
67
68
+ it ( 'NavigationCancelled error for nested async navigation' , ( done ) => {
69
+ const component = {
70
+ template : `<img />` ,
71
+ beforeRouteEnter ( to , from , next ) {
72
+ setTimeout ( ( ) => next ( ) , 100 )
73
+ }
74
+ }
75
+ const router = new VueRouter ( {
76
+ routes : [
77
+ { path : '/a' , component }
78
+ ]
79
+ } )
80
+
81
+ router . push ( '/a' ) . catch ( err => {
82
+ expect ( err . type ) . toBe ( NavigationFailureType . cancelled )
83
+ done ( )
84
+ } )
85
+ router . push ( '/' )
86
+ } )
87
+
68
88
it ( 'NavigationRedirected error' , done => {
69
89
const router = new VueRouter ( )
70
90
@@ -105,7 +125,7 @@ describe('error handling', () => {
105
125
} )
106
126
107
127
router . onError ( spy1 )
108
- router . onReady ( ( ) => { } , spy2 )
128
+ router . onReady ( ( ) => { } , spy2 )
109
129
110
130
router . push ( '/' ) . catch ( spy3 ) . finally ( ( ) => {
111
131
expect ( spy1 ) . toHaveBeenCalledWith ( err )
0 commit comments