-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupTests.tsx
63 lines (57 loc) · 1.61 KB
/
setupTests.tsx
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
56
57
58
59
60
61
62
63
import * as React from 'react'
import { vi } from 'vitest'
// Mock react-native
const mockPlatform = {
OS: 'ios',
Version: '14.0',
select: vi.fn((obj) => obj.ios),
}
const mockStyleSheet = {
create: vi.fn((obj) => obj),
hairlineWidth: 1,
flatten: vi.fn((style) => style),
}
const mockLinking = {
openURL: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
canOpenURL: vi.fn(),
getInitialURL: vi.fn(),
}
vi.mock('react-native', () => ({
ActivityIndicator: (props: any) => React.createElement('ActivityIndicator', props),
Button: (props: any) => React.createElement('Button', props),
Image: (props: any) => React.createElement('Image', props),
Linking: {
openURL: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
canOpenURL: vi.fn(),
getInitialURL: vi.fn(),
},
NativeModules: {
BlobModule: {
BLOB_URI_SCHEME: 'content',
BLOB_URI_HOST: 'localhost',
},
},
Platform: {
OS: 'ios',
Version: '14.0',
select: vi.fn((obj) => obj.ios),
},
Pressable: (props: any) => React.createElement('Pressable', props),
SafeAreaView: (props: any) => React.createElement('SafeAreaView', props),
StyleSheet: {
create: vi.fn((obj) => obj),
hairlineWidth: 1,
flatten: vi.fn((style) => style),
},
Text: (props: any) => React.createElement('Text', props),
View: (props: any) => React.createElement('View', props),
}))
vi.mock('react-native-webview', () => ({
WebView: (props: any) => React.createElement('WebView', props),
}))
// Export mocks for individual test usage
export { mockLinking, mockPlatform, mockStyleSheet }