-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathjest-setup.js
55 lines (44 loc) · 1.24 KB
/
jest-setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js'
import React from 'react'
import * as ReactNative from 'react-native'
import { enableFetchMocks } from 'jest-fetch-mock'
global.React = React
global.ReactNative = ReactNative
jest.mock('react-native-iphone-x-helper', () => ({
getStatusBarHeight: jest.fn(() => 44),
isIphoneX: jest.fn(() => true)
}))
global.React.useCallback = (f) => f
jest.useFakeTimers()
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper')
jest.mock('@react-native-community/netinfo', () => mockRNCNetInfo)
export const alert = jest.fn()
export const Alert = { alert }
export const dimensionWidth = 100
export const Dimensions = {
get: jest.fn().mockReturnValue({ width: dimensionWidth, height: 100 })
}
export const Image = 'Image'
export const keyboardDismiss = jest.fn()
export const Keyboard = {
dismiss: keyboardDismiss
}
enableFetchMocks()
export const Platform = {
...ReactNative.Platform,
OS: 'ios',
Version: 123,
isTesting: true,
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
select: (objs) => objs.ios
}
export default Object.setPrototypeOf(
{
Alert,
Dimensions,
Image,
Keyboard,
Platform
},
ReactNative
)