my fork of the bluesky client
at main 108 lines 2.9 kB view raw
1/* global jest */ 2import 'react-native-gesture-handler/jestSetup' 3// IMPORTANT: this is what's used in the native runtime 4import 'react-native-url-polyfill/auto' 5 6import {configure} from '@testing-library/react-native' 7 8configure({asyncUtilTimeout: 20000}) 9 10jest.mock('@react-native-async-storage/async-storage', () => 11 require('@react-native-async-storage/async-storage/jest/async-storage-mock'), 12) 13jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => { 14 const {EventEmitter} = require('events') 15 return { 16 __esModule: true, 17 default: EventEmitter, 18 } 19}) 20 21// Silence the warning: Animated: `useNativeDriver` is not supported 22jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper') 23 24jest.mock('@fortawesome/react-native-fontawesome', () => ({ 25 FontAwesomeIcon: '', 26})) 27 28jest.mock('react-native-safe-area-context', () => { 29 const inset = {top: 0, right: 0, bottom: 0, left: 0} 30 return { 31 SafeAreaProvider: jest.fn().mockImplementation(({children}) => children), 32 SafeAreaConsumer: jest 33 .fn() 34 .mockImplementation(({children}) => children(inset)), 35 useSafeAreaInsets: jest.fn().mockImplementation(() => inset), 36 } 37}) 38 39jest.mock('rn-fetch-blob', () => ({ 40 config: jest.fn().mockReturnThis(), 41 cancel: jest.fn(), 42 fetch: jest.fn(), 43})) 44 45jest.mock('expo-file-system', () => ({ 46 getInfoAsync: jest.fn().mockResolvedValue({exists: true, size: 100}), 47 deleteAsync: jest.fn(), 48})) 49 50jest.mock('expo-image-manipulator', () => ({ 51 manipulateAsync: jest.fn().mockResolvedValue({ 52 uri: 'file://resized-image', 53 }), 54 SaveFormat: jest.requireActual('expo-image-manipulator').SaveFormat, 55})) 56 57jest.mock('expo-camera', () => ({ 58 Camera: { 59 useCameraPermissions: jest.fn(() => [true]), 60 }, 61})) 62 63jest.mock('expo-media-library', () => ({ 64 __esModule: true, // this property makes it work 65 default: jest.fn(), 66 usePermissions: jest.fn(() => [true]), 67})) 68 69jest.mock('lande', () => ({ 70 __esModule: true, // this property makes it work 71 default: jest.fn().mockReturnValue([['eng']]), 72})) 73 74jest.mock('sentry-expo', () => ({ 75 init: () => jest.fn(), 76 Native: { 77 ReactNativeTracing: jest.fn().mockImplementation(() => ({ 78 start: jest.fn(), 79 stop: jest.fn(), 80 })), 81 ReactNavigationInstrumentation: jest.fn(), 82 }, 83})) 84 85jest.mock('crypto', () => ({})) 86 87jest.mock('expo-application', () => ({ 88 nativeApplicationVersion: '1.0.0', 89 nativeBuildVersion: '1', 90})) 91 92jest.mock('expo-modules-core', () => ({ 93 requireNativeModule: jest.fn().mockImplementation(moduleName => { 94 if (moduleName === 'ExpoPlatformInfo') { 95 return { 96 getIsReducedMotionEnabled: () => false, 97 } 98 } 99 if (moduleName === 'BottomSheet') { 100 return { 101 dismissAll: () => {}, 102 } 103 } 104 }), 105 requireNativeViewManager: jest.fn().mockImplementation(moduleName => { 106 return () => null 107 }), 108}))