@@ -87,10 +87,10 @@ describe('router.beforeEach', () => {
87
87
const spy = vi . fn ( )
88
88
const router = createRouter ( { routes } )
89
89
await router . push ( '/foo' )
90
- spy . mockImplementation ( ( to , from , next ) => {
90
+ spy . mockImplementation ( ( to , from ) => {
91
91
// only allow going to /other
92
- if ( to . fullPath !== '/other' ) next ( '/other' )
93
- else next ( )
92
+ if ( to . fullPath !== '/other' ) return '/other'
93
+ else return
94
94
} )
95
95
router . beforeEach ( spy )
96
96
expect ( spy ) . not . toHaveBeenCalled ( )
@@ -160,11 +160,11 @@ describe('router.beforeEach', () => {
160
160
const spy = vi . fn ( )
161
161
const router = createRouter ( { routes } )
162
162
await router . push ( '/' )
163
- spy . mockImplementation ( ( to , from , next ) => {
163
+ spy . mockImplementation ( ( to , from ) => {
164
164
// only allow going to /other
165
165
const i = Number ( to . params . i )
166
- if ( i >= 3 ) next ( )
167
- else next ( redirectFn ( String ( i + 1 ) ) )
166
+ if ( i >= 3 ) return
167
+ else return redirectFn ( String ( i + 1 ) )
168
168
} )
169
169
router . beforeEach ( spy )
170
170
expect ( spy ) . not . toHaveBeenCalled ( )
@@ -210,9 +210,9 @@ describe('router.beforeEach', () => {
210
210
it ( 'waits before navigating' , async ( ) => {
211
211
const [ promise , resolve ] = fakePromise ( )
212
212
const router = createRouter ( { routes } )
213
- router . beforeEach ( async ( to , from , next ) => {
213
+ router . beforeEach ( async ( to , from ) => {
214
214
await promise
215
- next ( )
215
+ return
216
216
} )
217
217
const p = router . push ( '/foo' )
218
218
expect ( router . currentRoute . value . fullPath ) . toBe ( '/' )
@@ -227,17 +227,17 @@ describe('router.beforeEach', () => {
227
227
const router = createRouter ( { routes } )
228
228
const guard1 = vi . fn ( )
229
229
let order = 0
230
- guard1 . mockImplementationOnce ( async ( to , from , next ) => {
230
+ guard1 . mockImplementationOnce ( async ( to , from ) => {
231
231
expect ( order ++ ) . toBe ( 0 )
232
232
await p1
233
- next ( )
233
+ return
234
234
} )
235
235
router . beforeEach ( guard1 )
236
236
const guard2 = vi . fn ( )
237
- guard2 . mockImplementationOnce ( async ( to , from , next ) => {
237
+ guard2 . mockImplementationOnce ( async ( to , from ) => {
238
238
expect ( order ++ ) . toBe ( 1 )
239
239
await p2
240
- next ( )
240
+ return
241
241
} )
242
242
router . beforeEach ( guard2 )
243
243
let navigation = router . push ( '/foo' )
0 commit comments