-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest-setup.js
More file actions
106 lines (96 loc) · 3.05 KB
/
Copy pathjest-setup.js
File metadata and controls
106 lines (96 loc) · 3.05 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import "@testing-library/react-native/extend-expect";
import React from "react";
import "react-native-gesture-handler/jestSetup";
import { setUpTests } from "react-native-reanimated";
import mockSafeAreaContext from "react-native-safe-area-context/jest/mock";
process.env = Object.assign(process.env, {
EXPO_PUBLIC_FLAGSMITH_ENVIRONMENT_ID: "flagsmithEnvironmentId",
EXPO_PUBLIC_SUPABASE_ANON_KEY: "supabaseAnonKey",
EXPO_PUBLIC_GEMINI_API_KEY: "geminiAPIKey",
EXPO_PUBLIC_VEXO_ANALYTICS_API_KEY: "",
EXPO_PUBLIC_SUPABASE_URL: "testing",
EXPO_PUBLIC_SENTRY_DSN: "sentryDsn",
NODE_ENV: "supabaseUrl",
});
setUpTests();
jest.mock("react-native-safe-area-context", () => mockSafeAreaContext);
jest.mock("@gorhom/bottom-sheet", () => {
const RN = jest.requireActual("react-native");
const BottomSheetModal = ({
backdropComponent,
handleComponent,
footerComponent,
children,
...props
}) => {
return (
<RN.View {...props}>
{backdropComponent && backdropComponent()}
{handleComponent && handleComponent()}
{children}
{footerComponent && footerComponent()}
</RN.View>
);
};
return {
__esModule: true,
...jest.requireActual("@gorhom/bottom-sheet/mock"),
...jest.requireActual("react-native-reanimated/mock"),
TouchableOpacity: jest.requireActual("react-native").TouchableOpacity,
BottomSheetBackdrop: jest.requireActual("react-native").View,
BottomSheetHandle: jest.requireActual("react-native").View,
BottomSheetFooter: jest.requireActual("react-native").View,
BottomSheetModal,
};
});
jest.mock("vexo-analytics", () => ({
identifyDevice: jest.fn(),
customEvent: jest.fn(),
vexo: jest.fn(),
}));
jest.mock("uuid", () => ({
v4: jest.fn(),
}));
jest.mock("@supabase/supabase-js", () => {
let testData = [
{
org_users: [{ id: "mockUserId", status: "active" }],
id: "mockedRoleId",
},
];
return {
createClient: jest.fn().mockImplementation(() => {
return {
update: jest.fn().mockImplementation(() => ({
select: jest.fn().mockReturnThis(),
order: jest.fn().mockReturnThis(),
gte: jest.fn().mockReturnThis(),
lte: jest.fn().mockReturnThis(),
eq: jest.fn().mockReturnThis(),
in: jest.fn().mockReturnThis(),
is: jest.fn().mockReturnThis(),
data: testData, // Use the data variable here
error: null,
})),
select: jest.fn().mockImplementation(() => ({
order: jest.fn().mockReturnThis(),
gte: jest.fn().mockReturnThis(),
lte: jest.fn().mockReturnThis(),
eq: jest.fn().mockReturnThis(),
in: jest.fn().mockReturnThis(),
is: jest.fn().mockReturnThis(),
data: testData, // Use the data variable here
error: null,
})),
from: jest.fn().mockReturnThis(),
};
}),
setTestData: (newData) => {
testData = newData;
},
};
});
export {};
jest.mock("react-native-worklets", () =>
require("react-native-worklets/lib/module/mock")
);