mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-01-01 10:28:40 -05:00
* 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
24 lines
685 B
TypeScript
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
|
|
};
|