2022-11-23 13:59:18 +00:00
|
|
|
const WebSocket = require('ws');
|
2023-06-19 13:39:12 +00:00
|
|
|
const { NativeModules } = require('react-native');
|
2022-11-23 13:59:18 +00:00
|
|
|
|
|
|
|
require('@react-native-async-storage/async-storage/jest/async-storage-mock');
|
|
|
|
require('react-native-gesture-handler/jestSetup');
|
2022-12-23 17:23:48 +00:00
|
|
|
require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests();
|
2022-11-23 13:59:18 +00:00
|
|
|
|
|
|
|
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
|
|
|
|
|
|
|
|
jest.mock('react-native-navigation', () => ({
|
2023-06-19 13:39:12 +00:00
|
|
|
getNavigationConstants: () => ({ constants: [] }),
|
|
|
|
Navigation: { constants: async () => {} },
|
2022-11-23 13:59:18 +00:00
|
|
|
}));
|
|
|
|
|
2023-02-21 05:42:33 +00:00
|
|
|
jest.mock('react-native-background-timer', () => ({}));
|
2022-11-23 13:59:18 +00:00
|
|
|
|
|
|
|
jest.mock('react-native-languages', () => ({
|
2023-06-19 13:39:12 +00:00
|
|
|
RNLanguages: {
|
|
|
|
language: 'en',
|
|
|
|
languages: ['en'],
|
|
|
|
},
|
|
|
|
default: {
|
|
|
|
language: 'en',
|
|
|
|
locale: 'en',
|
|
|
|
},
|
2022-11-23 13:59:18 +00:00
|
|
|
}));
|
|
|
|
|
2023-06-19 13:39:12 +00:00
|
|
|
jest.mock('react-native-permissions', () => require('react-native-permissions/mock'));
|
2022-12-23 17:23:48 +00:00
|
|
|
|
|
|
|
jest.mock('@react-native-community/audio-toolkit', () => ({
|
2023-06-19 13:39:12 +00:00
|
|
|
Recorder: jest.fn().mockImplementation(() => ({
|
|
|
|
prepare: jest.fn(),
|
|
|
|
record: jest.fn(),
|
|
|
|
toggleRecord: jest.fn(),
|
|
|
|
pause: jest.fn(),
|
|
|
|
stop: jest.fn(),
|
|
|
|
on: jest.fn(),
|
|
|
|
})),
|
|
|
|
Player: jest.fn().mockImplementation(() => ({
|
|
|
|
prepare: jest.fn(),
|
|
|
|
playPause: jest.fn(),
|
|
|
|
play: jest.fn(),
|
|
|
|
pause: jest.fn(),
|
|
|
|
stop: jest.fn(),
|
|
|
|
seek: jest.fn(),
|
|
|
|
on: jest.fn(),
|
|
|
|
})),
|
|
|
|
MediaStates: {
|
|
|
|
DESTROYED: -2,
|
|
|
|
ERROR: -1,
|
|
|
|
IDLE: 0,
|
|
|
|
PREPARING: 1,
|
|
|
|
PREPARED: 2,
|
|
|
|
SEEKING: 3,
|
|
|
|
PLAYING: 4,
|
|
|
|
RECORDING: 4,
|
|
|
|
PAUSED: 5,
|
|
|
|
},
|
|
|
|
PlaybackCategories: {
|
|
|
|
Playback: 1,
|
|
|
|
Ambient: 2,
|
|
|
|
SoloAmbient: 3,
|
|
|
|
},
|
2022-12-23 17:23:48 +00:00
|
|
|
}));
|
|
|
|
|
2023-06-19 13:39:12 +00:00
|
|
|
jest.mock('i18n-js', () => ({
|
|
|
|
...jest.requireActual('i18n-js'),
|
|
|
|
t: (label) => `tx:${label}`,
|
2023-03-01 15:47:02 +00:00
|
|
|
}));
|
|
|
|
|
2023-06-19 13:39:12 +00:00
|
|
|
jest.mock('react-native-blob-util', () => ({
|
|
|
|
default: {
|
|
|
|
config: jest.fn().mockReturnValue({
|
|
|
|
fetch: jest.fn(),
|
|
|
|
}),
|
|
|
|
},
|
2023-03-13 17:08:03 +00:00
|
|
|
}));
|
|
|
|
|
2023-07-26 07:11:17 +00:00
|
|
|
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
|
|
|
|
|
2022-11-23 13:59:18 +00:00
|
|
|
NativeModules.ReactLocalization = {
|
2023-06-19 13:39:12 +00:00
|
|
|
language: 'en',
|
|
|
|
locale: 'en',
|
2022-11-23 13:59:18 +00:00
|
|
|
};
|
|
|
|
global.navigator = {
|
2023-06-19 13:39:12 +00:00
|
|
|
userAgent: 'node',
|
2023-02-21 05:42:33 +00:00
|
|
|
};
|
2022-11-23 13:59:18 +00:00
|
|
|
|
2023-02-21 05:42:33 +00:00
|
|
|
global.WebSocket = WebSocket;
|