@@ -314,19 +314,23 @@ describe('Router', () => {
314
314
expect ( route2 . path ) . toBe ( '/optional' )
315
315
expect ( route2 . params ) . toEqual ( { } )
316
316
317
- // but keeps empty strings
318
- const route3 = router . resolve ( {
319
- name : 'optional' ,
320
- params : { p : '' } ,
321
- } )
322
- expect ( route3 . path ) . toBe ( '/optional' )
323
- expect ( route3 . params ) . toEqual ( { p : '' } )
324
-
325
317
await router . push ( { name : 'optional' , params : { p : null } } )
326
318
expect ( router . currentRoute . value . params ) . toEqual ( { } )
327
319
await router . push ( { name : 'optional' , params : { } } )
328
320
} )
329
321
322
+ it ( 'removes null/undefined params when current location has it' , async ( ) => {
323
+ const { router } = await newRouter ( )
324
+
325
+ await router . push ( { name : 'optional' , params : { p : 'a' } } )
326
+ await router . push ( { name : 'optional' , params : { p : null } } )
327
+ expect ( router . currentRoute . value . params ) . toEqual ( { } )
328
+
329
+ await router . push ( { name : 'optional' , params : { p : 'a' } } )
330
+ await router . push ( { name : 'optional' , params : { p : undefined } } )
331
+ expect ( router . currentRoute . value . params ) . toEqual ( { } )
332
+ } )
333
+
330
334
it ( 'keeps empty strings' , async ( ) => {
331
335
const { router } = await newRouter ( )
332
336
const route1 = router . resolve ( { name : 'optional' , params : { p : '' } } )
0 commit comments