forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1/* global jest */
2import 'react-native-gesture-handler/jestSetup'
3
4import {configure} from '@testing-library/react-native'
5
6configure({asyncUtilTimeout: 20000})
7
8jest.mock('@react-native-async-storage/async-storage', () =>
9 require('@react-native-async-storage/async-storage/jest/async-storage-mock'),
10)
11jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => {
12 // eslint-disable-next-line import-x/no-nodejs-modules
13 const {EventEmitter} = require('events')
14 return {
15 __esModule: true,
16 default: EventEmitter,
17 }
18})
19
20jest.mock('@fortawesome/react-native-fontawesome', () => ({
21 FontAwesomeIcon: '',
22}))
23
24jest.mock('react-native-safe-area-context', () => {
25 const inset = {top: 0, right: 0, bottom: 0, left: 0}
26 return {
27 SafeAreaProvider: jest.fn().mockImplementation(({children}) => children),
28 SafeAreaConsumer: jest
29 .fn()
30 .mockImplementation(({children}) => children(inset)),
31 useSafeAreaInsets: jest.fn().mockImplementation(() => inset),
32 }
33})
34
35jest.mock('expo-file-system/legacy', () => ({
36 getInfoAsync: jest.fn().mockResolvedValue({exists: true, size: 100}),
37 deleteAsync: jest.fn(),
38 moveAsync: jest.fn().mockResolvedValue(undefined),
39 createDownloadResumable: jest.fn(),
40}))
41
42jest.mock('expo-image-manipulator', () => ({
43 manipulateAsync: jest.fn().mockResolvedValue({
44 uri: 'file://resized-image',
45 }),
46 SaveFormat: {
47 JPEG: 'jpeg',
48 WEBP: 'webp',
49 },
50}))
51
52jest.mock('expo-camera', () => ({
53 Camera: {
54 useCameraPermissions: jest.fn(() => [true]),
55 },
56}))
57
58jest.mock('expo-media-library', () => ({
59 __esModule: true, // this property makes it work
60 default: jest.fn(),
61 usePermissions: jest.fn(() => [true]),
62}))
63
64jest.mock('@bsky.app/expo-guess-language', () => ({
65 guessLanguageSync: jest
66 .fn()
67 .mockReturnValue([{language: 'en', confidence: 1}]),
68 guessLanguageAsync: jest
69 .fn()
70 .mockResolvedValue([{language: 'en', confidence: 1}]),
71}))
72
73jest.mock('sentry-expo', () => ({
74 init: () => jest.fn(),
75 Native: {
76 ReactNativeTracing: jest.fn().mockImplementation(() => ({
77 start: jest.fn(),
78 stop: jest.fn(),
79 })),
80 ReactNavigationInstrumentation: jest.fn(),
81 },
82}))
83
84jest.mock('crypto', () => ({}))
85
86jest.mock('expo-application', () => ({
87 nativeApplicationVersion: '1.0.0',
88 nativeBuildVersion: '1',
89}))
90
91jest.mock('expo-modules-core', () => ({
92 requireNativeModule: jest.fn().mockImplementation(moduleName => {
93 if (moduleName === 'ExpoPlatformInfo') {
94 return {
95 getIsReducedMotionEnabled: () => false,
96 }
97 }
98 if (moduleName === 'BottomSheet') {
99 return {
100 dismissAll: () => {},
101 }
102 }
103 }),
104 requireNativeViewManager: jest.fn().mockImplementation(_ => {
105 return () => null
106 }),
107 createPermissionHook: () => () => [true],
108}))
109
110jest.mock('expo-localization', () => ({
111 getLocales: () => [],
112}))