@@ -44,6 +44,10 @@ jest.mock('@src/ROUTES', () => ({
4444 path : 'suffix-b-from-multi' ,
4545 entryScreens : [ 'DynamicMultiSegScreen' ] ,
4646 } ,
47+ WILDCARD_SUFFIX : {
48+ path : 'wildcard-suffix' ,
49+ entryScreens : [ '*' ] ,
50+ } ,
4751 } ,
4852} ) ) ;
4953
@@ -62,6 +66,7 @@ describe('getStateFromPath', () => {
6266 const dynamicSuffixBState = { routes : [ { name : 'DynamicSuffixBScreen' } ] } ;
6367 const dynamicMultiSegState = { routes : [ { name : 'DynamicMultiSegScreen' , params : focusedRouteParams } ] } ;
6468 const dynamicMultiSegLayerState = { routes : [ { name : 'DynamicMultiSegLayerScreen' } ] } ;
69+ const dynamicWildcardState = { routes : [ { name : 'DynamicWildcardScreen' } ] } ;
6570
6671 beforeEach ( ( ) => {
6772 jest . clearAllMocks ( ) ;
@@ -79,6 +84,9 @@ describe('getStateFromPath', () => {
7984 if ( dynamicRouteKey === 'MULTI_SEG_LAYER' ) {
8085 return dynamicMultiSegLayerState ;
8186 }
87+ if ( dynamicRouteKey === 'WILDCARD_SUFFIX' ) {
88+ return dynamicWildcardState ;
89+ }
8290 return { routes : [ { name : 'UnknownDynamic' } ] } ;
8391 } ) ;
8492 } ) ;
@@ -159,4 +167,27 @@ describe('getStateFromPath', () => {
159167 expect ( mockGetStateForDynamicRoute ) . toHaveBeenCalledWith ( fullPath , 'MULTI_SEG_LAYER' , focusedRouteParams ) ;
160168 } ) ;
161169 } ) ;
170+
171+ describe ( 'wildcard entryScreens' , ( ) => {
172+ it ( 'should authorize any focused screen when entryScreens contains wildcard' , ( ) => {
173+ const fullPath = '/base/wildcard-suffix' ;
174+
175+ const result = getStateFromPath ( fullPath as unknown as Route ) ;
176+
177+ expect ( result ) . toBe ( dynamicWildcardState ) ;
178+ expect ( mockGetStateForDynamicRoute ) . toHaveBeenCalledWith ( fullPath , 'WILDCARD_SUFFIX' , focusedRouteParams ) ;
179+ expect ( mockLogWarn ) . not . toHaveBeenCalled ( ) ;
180+ } ) ;
181+
182+ it ( 'should authorize wildcard in a layered scenario where the inner screen is not explicitly listed' , ( ) => {
183+ const fullPath = '/base/suffix-a/wildcard-suffix' ;
184+
185+ const result = getStateFromPath ( fullPath as unknown as Route ) ;
186+
187+ expect ( result ) . toBe ( dynamicWildcardState ) ;
188+ expect ( mockGetStateForDynamicRoute ) . toHaveBeenCalledWith ( '/base/suffix-a' , 'SUFFIX_A' , focusedRouteParams ) ;
189+ expect ( mockGetStateForDynamicRoute ) . toHaveBeenCalledWith ( fullPath , 'WILDCARD_SUFFIX' , focusedRouteParams ) ;
190+ expect ( mockLogWarn ) . not . toHaveBeenCalled ( ) ;
191+ } ) ;
192+ } ) ;
162193} ) ;
0 commit comments