File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ import navigationRef from '@libs/Navigation/navigationRef';
44import type { Route } from '@src/ROUTES' ;
55
66jest . mock ( '@react-navigation/native' , ( ) => {
7- const actual = jest . requireActual ( '@react-navigation/native' ) ;
8- return Object . assign ( { } , actual , {
7+ const actual = jest . requireActual ( '@react-navigation/native' ) as typeof import ( '@react-navigation/native' ) ;
8+ return {
9+ ...actual ,
910 getPathFromState : jest . fn ( ) . mockReturnValue ( '/settings/profile?backTo=settings' ) ,
10- } ) ;
11+ } ;
1112} ) ;
1213
1314describe ( 'Navigation' , ( ) => {
@@ -17,10 +18,9 @@ describe('Navigation', () => {
1718
1819 beforeEach ( ( ) => {
1920 // Minimal stubs so getActiveRoute() can derive a path without rendering navigation containers.
20- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21- ( navigationRef as any ) . getRootState = jest . fn ( ) . mockReturnValue ( { } ) ;
22- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23- ( navigationRef as any ) . current = { getCurrentRoute : jest . fn ( ) . mockReturnValue ( { name : 'DUMMY' } ) } ;
21+ const ref = navigationRef as typeof navigationRef & { current : { getCurrentRoute : ( ) => { name : string } } | null } ;
22+ ref . current = { getCurrentRoute : jest . fn ( ) . mockReturnValue ( { name : 'test' } ) } ;
23+ jest . spyOn ( navigationRef , 'getRootState' ) . mockReturnValue ( { } as unknown as ReturnType < typeof navigationRef . getRootState > ) ;
2424 jest . spyOn ( navigationRef , 'isReady' ) . mockReturnValue ( true ) ;
2525 } ) ;
2626
You can’t perform that action at this time.
0 commit comments