@@ -16,9 +16,10 @@ const {triggerTransitionEnd, addListener} = isJestEnv
16
16
addListener : ( ) => { } ,
17
17
} ;
18
18
19
+ const realOrMockedUseNavigation = isJestEnv ? realReactNavigation . useNavigation : { } ;
19
20
const useNavigation = ( ) => ( {
20
- ...realReactNavigation . useNavigation ,
21
- navigate : jest . fn ( ) ,
21
+ ...realOrMockedUseNavigation ,
22
+ navigate : isJestEnv ? jest . fn ( ) : ( ) => { } ,
22
23
getState : ( ) => ( {
23
24
routes : [ ] ,
24
25
} ) ,
@@ -30,17 +31,20 @@ type NativeNavigationMock = typeof ReactNavigation & {
30
31
} ;
31
32
32
33
export * from '@react-navigation/core' ;
33
- const Link = realReactNavigation . Link ;
34
- const LinkingContext = realReactNavigation . LinkingContext ;
35
- const NavigationContainer = realReactNavigation . NavigationContainer ;
36
- const ServerContainer = realReactNavigation . ServerContainer ;
37
- const DarkTheme = realReactNavigation . DarkTheme ;
38
- const DefaultTheme = realReactNavigation . DefaultTheme ;
39
- const ThemeProvider = realReactNavigation . ThemeProvider ;
40
- const useLinkBuilder = realReactNavigation . useLinkBuilder ;
41
- const useLinkProps = realReactNavigation . useLinkProps ;
42
- const useLinkTo = realReactNavigation . useLinkTo ;
43
- const useScrollToTop = realReactNavigation . useScrollToTop ;
34
+ const Link = isJestEnv ? realReactNavigation . Link : ( ) => null ;
35
+ const LinkingContext = isJestEnv ? realReactNavigation . LinkingContext : ( ) => null ;
36
+ const NavigationContainer = isJestEnv ? realReactNavigation . NavigationContainer : ( ) => null ;
37
+ const ServerContainer = isJestEnv ? realReactNavigation . ServerContainer : ( ) => null ;
38
+ const DarkTheme = isJestEnv ? realReactNavigation . DarkTheme : { } ;
39
+ const DefaultTheme = isJestEnv ? realReactNavigation . DefaultTheme : { } ;
40
+ const ThemeProvider = isJestEnv ? realReactNavigation . ThemeProvider : ( ) => null ;
41
+ const useLinkBuilder = isJestEnv ? realReactNavigation . useLinkBuilder : ( ) => null ;
42
+ const useLinkProps = isJestEnv ? realReactNavigation . useLinkProps : ( ) => null ;
43
+ const useLinkTo = isJestEnv ? realReactNavigation . useLinkTo : ( ) => null ;
44
+ const useScrollToTop = isJestEnv ? realReactNavigation . useScrollToTop : ( ) => null ;
45
+ const useRoute = isJestEnv ? realReactNavigation . useRoute : ( ) => ( { params : { } } ) ;
46
+ const useFocusEffect = isJestEnv ? realReactNavigation . useFocusEffect : ( callback : ( ) => void ) => callback ( ) ;
47
+
44
48
export {
45
49
// Overriden modules
46
50
useIsFocused ,
@@ -60,6 +64,8 @@ export {
60
64
useLinkProps ,
61
65
useLinkTo ,
62
66
useScrollToTop ,
67
+ useRoute ,
68
+ useFocusEffect ,
63
69
} ;
64
70
65
71
export type { NativeNavigationMock } ;
0 commit comments