11import { afterEach , describe , expect , it } from 'vitest' ;
2- import { getBasePath , getConfigString } from './utils' ;
2+ import { filterParallelRouteParams , getBasePath , getConfigString } from './utils' ;
33
44const processSave = { ...process } ;
55const envSave = { ...process . env } ;
@@ -9,6 +9,49 @@ afterEach(() => {
99 process . env = { ...envSave } ;
1010} ) ;
1111
12+ describe ( 'filterParallelRouteParams()' , ( ) => {
13+ it ( 'filters single-segment slot catch-all from static main route' , ( ) => {
14+ // @sidebar /[...catchAll] matched "dashboard" — a single segment not in main route
15+ const result = filterParallelRouteParams (
16+ { catchAll : [ 'dashboard' ] } ,
17+ [ 'dashboard' ] ,
18+ ) ;
19+ expect ( result ) . toEqual ( { } ) ;
20+ } ) ;
21+
22+ it ( 'keeps multi-segment catch-all that appears in segments' , ( ) => {
23+ const result = filterParallelRouteParams (
24+ { slug : [ 'blog' , 'my-post' ] } ,
25+ [ 'blog/my-post' ] ,
26+ ) ;
27+ expect ( result ) . toEqual ( { slug : [ 'blog' , 'my-post' ] } ) ;
28+ } ) ;
29+
30+ it ( 'keeps string params and filters slot array params' , ( ) => {
31+ const result = filterParallelRouteParams (
32+ { id : 'abc' , catchAll : [ 'dashboard' ] } ,
33+ [ 'some-other-segment' ] ,
34+ ) ;
35+ expect ( result ) . toEqual ( { id : 'abc' } ) ;
36+ } ) ;
37+
38+ it ( 'filters multi-segment slot catch-all whose joined value is not in segments' , ( ) => {
39+ const result = filterParallelRouteParams (
40+ { catchAll : [ 'a' , 'b' ] } ,
41+ [ 'c' , 'd' ] ,
42+ ) ;
43+ expect ( result ) . toEqual ( { } ) ;
44+ } ) ;
45+
46+ it ( 'keeps all params when segments is empty' , ( ) => {
47+ const result = filterParallelRouteParams (
48+ { id : 'abc' , slug : [ 'x' , 'y' ] } ,
49+ [ ] ,
50+ ) ;
51+ expect ( result ) . toEqual ( { id : 'abc' } ) ;
52+ } ) ;
53+ } ) ;
54+
1255describe ( 'getBasePath()' , ( ) => {
1356 it ( 'returns null without process' , ( ) => {
1457 // @ts -expect-error -- yes, we want to completely drop process for this test!!
0 commit comments