Files
iNaturalistReactNative/__mocks__/@react-navigation/native.ts
Amanda Bullington cf70a4358a Move modules from jest setup to __mocks__ (#1949)
* Get a few mocks working in __mocks__ folder

* Move more mocks into __mocks__

* Move mocks

* Move zustand mock

* Add more mocks to __mocks__

* More mocks

* Move more files to __mocks__ and audit existing mocks

* Mock react navigation in __mocks__

* Restore test to help with imports after jest env torn down

* Add fake timer to integration test with userEvent

* Add RN paper mock
2024-08-11 11:27:52 -07:00

24 lines
685 B
TypeScript

// 20240806 amanda - best practice for react navigation
// is actually not to mock navigation at all. I removed
// useFocusEffect so we can test how that actually works in
// components; it requires using the wrapInNavigationContainer
// helper around components with useFocusEffect
// https://reactnavigation.org/docs/testing/#best-practices
const actualNav = jest.requireActual( "@react-navigation/native" );
const useRoute = jest.fn( ( ) => ( { params: {} } ) );
const useNavigation = ( ) => ( {
addListener: jest.fn( ),
canGoBack: jest.fn( ( ) => true ),
goBack: jest.fn( ),
setOptions: jest.fn( )
} );
module.exports = {
...actualNav,
useNavigation,
useRoute
};