@@ -9,7 +9,7 @@ describe('error handling', () => {
99 const router = new VueRouter ( )
1010 const err = new Error ( 'foo' )
1111 router . beforeEach ( ( ) => { throw err } )
12- router . onError ( ( ) => { } )
12+ router . onError ( ( ) => { } )
1313
1414 const onReady = jasmine . createSpy ( 'ready' )
1515 const onError = jasmine . createSpy ( 'error' )
@@ -65,6 +65,26 @@ describe('error handling', () => {
6565 router . push ( '/' )
6666 } )
6767
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+
6888 it ( 'NavigationRedirected error' , done => {
6989 const router = new VueRouter ( )
7090
@@ -105,7 +125,7 @@ describe('error handling', () => {
105125 } )
106126
107127 router . onError ( spy1 )
108- router . onReady ( ( ) => { } , spy2 )
128+ router . onReady ( ( ) => { } , spy2 )
109129
110130 router . push ( '/' ) . catch ( spy3 ) . finally ( ( ) => {
111131 expect ( spy1 ) . toHaveBeenCalledWith ( err )
0 commit comments