2021-02-23 05:32:47 +00:00
|
|
|
/**
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
2021-10-07 05:06:01 +00:00
|
|
|
|
2022-03-29 06:51:33 +00:00
|
|
|
/* AsyncStorage Mock */
|
|
|
|
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
|
|
|
|
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
|
|
|
|
|
2021-11-16 16:23:37 +00:00
|
|
|
/* Fetch and AbortController Mocks */
|
2021-10-07 05:06:01 +00:00
|
|
|
import { enableFetchMocks } from 'jest-fetch-mock';
|
2021-10-08 04:51:51 +00:00
|
|
|
import { AbortController } from 'node-abort-controller';
|
2021-10-07 05:06:01 +00:00
|
|
|
|
2022-03-23 15:54:02 +00:00
|
|
|
// DOMException is not polyfilled in released version of jest-fetch-mock
|
|
|
|
// refs: https://github.com/jefflau/jest-fetch-mock/pull/160
|
|
|
|
if (typeof DOMException === 'undefined') {
|
|
|
|
global.DOMException = require('domexception');
|
|
|
|
}
|
|
|
|
|
2021-02-23 05:32:47 +00:00
|
|
|
global.AbortController = AbortController;
|
|
|
|
|
|
|
|
enableFetchMocks();
|
2021-11-16 16:23:37 +00:00
|
|
|
|
|
|
|
/* React Navigation Mocks */
|
|
|
|
import 'react-native-gesture-handler/jestSetup';
|
|
|
|
|
|
|
|
jest.mock('react-native-reanimated', () => {
|
|
|
|
const Reanimated = require('react-native-reanimated/mock');
|
|
|
|
|
|
|
|
// The mock for `call` immediately calls the callback which is incorrect
|
|
|
|
// So we override it with a no-op
|
2021-11-22 14:56:33 +00:00
|
|
|
Reanimated.default.call = () => { /* no-op */ };
|
2021-11-16 16:23:37 +00:00
|
|
|
|
|
|
|
return Reanimated;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
|
|
|
|
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
|
|
|
|
|
|
// Workaround for process failing: https://github.com/react-navigation/react-navigation/issues/9568
|
|
|
|
jest.mock('@react-navigation/native/lib/commonjs/useLinking.native', () => ({
|
|
|
|
default: () => ({ getInitialState: { then: jest.fn() } }),
|
|
|
|
__esModule: true
|
|
|
|
}));
|
2022-03-28 15:26:10 +00:00
|
|
|
|
|
|
|
/* Safe Area Context Mocks */
|
|
|
|
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';
|
|
|
|
jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);
|
2022-12-01 16:18:26 +00:00
|
|
|
|
|
|
|
/* UUID Mocks */
|
|
|
|
jest.mock('uuid', () => {
|
|
|
|
let value = 0;
|
|
|
|
return {
|
|
|
|
v4: () => `uuid-${value++}`
|
|
|
|
};
|
|
|
|
});
|