Files
react-navigation/packages/stack/jest-setup.js
Satyajit Sahoo 8b11e4df0c chore: reuse the stack code from react navigation 5
The code for the stack is almost the same as v5, with the only differences being the types and the navigation object. To avoid making same changes in 2 places which error-prone, I decided to reuse the same code. Due to the differences, it's not possible to just use it as a dependency, so I followed this approach:
- Copy the source files on post install and apply patches to make it work with React Navigation 4
- When we need to make changes, we can make them in v5 repo and update the version here, most of the time it wouldn't need any extra work
- If we need to make v4 specific changes, we can change the code in vendor/ and then re-generate the patch with `yarn patch`
2019-12-10 15:22:12 +01:00

40 lines
775 B
JavaScript

/* eslint-env jest */
jest.mock('@react-native-community/masked-view', () => () => null);
jest.mock('react-native-safe-area-context', () => {
const React = require('react');
const SafeAreaContext = React.createContext({
top: 0,
left: 0,
right: 0,
bottom: 0,
});
return {
__esModule: true,
SafeAreaContext,
SafeAreaProvider: SafeAreaContext.Provider,
SafeAreaConsumer: SafeAreaContext.Consumer,
};
});
jest.mock('react-native-gesture-handler', () => ({
PanGestureHandler: 'PanGestureHandler',
BaseButton: 'BaseButton',
State: {
UNDETERMINED: 0,
FAILED: 1,
BEGAN: 2,
CANCELLED: 3,
ACTIVE: 4,
END: 5,
},
}));
jest.mock('react-native-reanimated', () =>
require('react-native-reanimated/mock')
);