// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {configure} from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; configure({adapter: new Adapter()}); /* eslint-disable no-console */ jest.mock('NativeModules', () => { return { UIManager: { RCTView: { directEventTypes: {}, }, }, BlurAppScreen: () => true, MattermostManaged: { getConfig: jest.fn(), }, PlatformConstants: { forceTouchAvailable: false, }, RNGestureHandlerModule: { State: { BEGAN: 'BEGAN', FAILED: 'FAILED', ACTIVE: 'ACTIVE', END: 'END', }, }, }; }); jest.mock('NativeEventEmitter'); jest.mock('react-native-device-info', () => { return { getVersion: () => '0.0.0', getBuildNumber: () => '0', getModel: () => 'iPhone X', }; }); let logs; let warns; let errors; beforeAll(() => { console.originalLog = console.log; console.log = jest.fn((...params) => { console.originalLog(...params); logs.push(params); }); console.originalWarn = console.warn; console.warn = jest.fn((...params) => { console.originalWarn(...params); warns.push(params); }); console.originalError = console.error; console.error = jest.fn((...params) => { console.originalError(...params); errors.push(params); }); }); beforeEach(() => { logs = []; warns = []; errors = []; }); afterEach(() => { if (logs.length > 0 || warns.length > 0 || errors.length > 0) { throw new Error('Unexpected console logs' + logs + warns + errors); } }); jest.mock('rn-fetch-blob', () => ({ fs: { dirs: { DocumentDir: () => jest.fn(), CacheDir: () => jest.fn(), }, }, })); jest.mock('rn-fetch-blob/fs', () => ({ dirs: { DocumentDir: () => jest.fn(), CacheDir: () => jest.fn(), }, })); global.requestAnimationFrame = (callback) => { setTimeout(callback, 0); };