-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
91 lines (85 loc) · 2.12 KB
/
jest.setup.js
File metadata and controls
91 lines (85 loc) · 2.12 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import '@testing-library/jest-native/extend-expect';
// Mock console methods to reduce noise in tests
global.console = {
...console,
log: jest.fn(),
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
};
// Mock navigation
jest.mock('@react-navigation/native', () => ({
useNavigation: () => ({
navigate: jest.fn(),
replace: jest.fn(),
goBack: jest.fn(),
}),
useFocusEffect: jest.fn(),
}));
// Mock Firebase Auth
jest.mock('@react-native-firebase/auth', () => ({
auth: () => ({
currentUser: {
uid: 'test-user-id',
email: 'test@example.com',
displayName: 'Test User',
},
signOut: jest.fn().mockResolvedValue(true),
}),
}));
// Mock Google Sign-In
jest.mock('@react-native-google-signin/google-signin', () => ({
GoogleSignin: {
configure: jest.fn(),
hasPlayServices: jest.fn().mockResolvedValue(true),
signIn: jest.fn().mockResolvedValue({
user: {
id: 'test-id',
name: 'Test User',
email: 'test@example.com',
},
idToken: 'test-token',
}),
signOut: jest.fn().mockResolvedValue(true),
isSignedIn: jest.fn().mockResolvedValue(false),
},
}));
// Mock Push Notifications
jest.mock('@react-native-community/push-notification-ios', () => ({
requestPermissions: jest.fn().mockResolvedValue(true),
scheduleLocalNotification: jest.fn(),
cancelAllLocalNotifications: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
}));
// Mock MMKV Storage
jest.mock('react-native-mmkv-storage', () => ({
MMKVLoader: function () {
return {
withEncryption: () => ({
initialize: () => ({
getString: jest.fn(),
setString: jest.fn(),
removeItem: jest.fn(),
}),
}),
};
},
useMMKVStorage: jest.fn((key, storage) => {
if (key === 'user') {
return [
{
uid: 'test-user-id',
email: 'test@example.com',
displayName: 'Test User',
},
jest.fn(),
];
}
if (key === 'timezone') {
return ['America/New_York', jest.fn()];
}
return [null, jest.fn()];
}),
}));