@terreno/test 57.18.0 → 57.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +2074 -0
  2. package/README.md +6 -0
  3. package/dist/assertions/expectAPIError.d.ts +18 -0
  4. package/dist/assertions/expectAPIError.js +33 -0
  5. package/dist/assertions/strictResponseProperties.d.ts +14 -0
  6. package/dist/assertions/strictResponseProperties.js +37 -0
  7. package/dist/cache/mongoTestCache.js +2 -2
  8. package/dist/cli/collectFiles.d.ts +38 -0
  9. package/dist/cli/collectFiles.js +73 -0
  10. package/dist/cli/testHygiene.d.ts +134 -0
  11. package/dist/cli/testHygiene.js +357 -0
  12. package/dist/cli/testHygieneCli.d.ts +2 -0
  13. package/dist/cli/testHygieneCli.js +5 -0
  14. package/dist/cli/testHygieneRules.d.ts +58 -0
  15. package/dist/cli/testHygieneRules.js +517 -0
  16. package/dist/cli/testShard.d.ts +155 -0
  17. package/dist/cli/testShard.js +377 -0
  18. package/dist/cli/testShardCli.d.ts +2 -0
  19. package/dist/cli/testShardCli.js +5 -0
  20. package/dist/expo/authTokenStorage.d.ts +76 -0
  21. package/dist/expo/authTokenStorage.js +160 -0
  22. package/dist/expo/expoModuleMocks.d.ts +24 -0
  23. package/dist/expo/expoModuleMocks.js +456 -0
  24. package/dist/expo/libraryModuleMocks.d.ts +17 -0
  25. package/dist/expo/libraryModuleMocks.js +347 -0
  26. package/dist/expo/mockHelpers.d.ts +39 -0
  27. package/dist/expo/mockHelpers.js +45 -0
  28. package/dist/expo/mockModuleAliases.d.ts +50 -0
  29. package/dist/expo/mockModuleAliases.js +174 -0
  30. package/dist/expo/reactNativeMock.d.ts +39 -0
  31. package/dist/expo/reactNativeMock.js +421 -0
  32. package/dist/expo/registerExpoTestEnvironment.d.ts +69 -0
  33. package/dist/expo/registerExpoTestEnvironment.js +165 -0
  34. package/dist/expo/renderWithTerreno.d.ts +47 -0
  35. package/dist/expo/renderWithTerreno.js +47 -0
  36. package/dist/http/authWithToken.d.ts +20 -0
  37. package/dist/http/authWithToken.js +30 -0
  38. package/dist/index.d.ts +14 -1
  39. package/dist/index.js +33 -1
  40. package/dist/logging/silenceLogs.js +0 -2
  41. package/dist/mocks/aiSdk.d.ts +77 -0
  42. package/dist/mocks/aiSdk.js +102 -0
  43. package/dist/mocks/cloudTasks.d.ts +91 -0
  44. package/dist/mocks/cloudTasks.js +197 -0
  45. package/dist/mocks/expoPush.d.ts +53 -0
  46. package/dist/mocks/expoPush.js +57 -0
  47. package/dist/mocks/gcs.d.ts +101 -0
  48. package/dist/mocks/gcs.js +162 -0
  49. package/dist/mocks/googleAuth.d.ts +69 -0
  50. package/dist/mocks/googleAuth.js +55 -0
  51. package/dist/mocks/mockGroup.d.ts +11 -0
  52. package/dist/mocks/mockGroup.js +21 -0
  53. package/dist/mocks/notifiers.d.ts +21 -0
  54. package/dist/mocks/notifiers.js +26 -0
  55. package/dist/mocks/sendgrid.d.ts +22 -0
  56. package/dist/mocks/sendgrid.js +32 -0
  57. package/dist/mocks/twilio.d.ts +72 -0
  58. package/dist/mocks/twilio.js +64 -0
  59. package/dist/preload/registerBackendPreload.js +4 -1
  60. package/dist/time/freezeTime.d.ts +16 -0
  61. package/dist/time/freezeTime.js +49 -0
  62. package/dist/transaction/testTransaction.d.ts +43 -6
  63. package/dist/transaction/testTransaction.js +371 -92
  64. package/dist/utils/waitUntil.d.ts +22 -0
  65. package/dist/utils/waitUntil.js +34 -0
  66. package/package.json +53 -8
  67. package/src/assertions/expectAPIError.ts +51 -0
  68. package/src/assertions/strictResponseProperties.ts +42 -0
  69. package/src/cache/mongoTestCache.ts +2 -2
  70. package/src/cli/collectFiles.ts +115 -0
  71. package/src/cli/testHygiene.ts +539 -0
  72. package/src/cli/testHygieneCli.ts +4 -0
  73. package/src/cli/testHygieneRules.ts +719 -0
  74. package/src/cli/testShard.ts +532 -0
  75. package/src/cli/testShardCli.ts +4 -0
  76. package/src/expo/authTokenStorage.ts +198 -0
  77. package/src/expo/expoModuleMocks.ts +503 -0
  78. package/src/expo/libraryModuleMocks.ts +411 -0
  79. package/src/expo/mockHelpers.ts +73 -0
  80. package/src/expo/mockModuleAliases.ts +252 -0
  81. package/src/expo/reactNativeMock.ts +534 -0
  82. package/src/expo/registerExpoTestEnvironment.ts +262 -0
  83. package/src/expo/renderWithTerreno.ts +79 -0
  84. package/src/http/authWithToken.ts +38 -0
  85. package/src/index.ts +82 -1
  86. package/src/logging/silenceLogs.ts +0 -2
  87. package/src/mocks/aiSdk.ts +199 -0
  88. package/src/mocks/cloudTasks.ts +323 -0
  89. package/src/mocks/expoPush.ts +134 -0
  90. package/src/mocks/gcs.ts +305 -0
  91. package/src/mocks/googleAuth.ts +136 -0
  92. package/src/mocks/mockGroup.ts +32 -0
  93. package/src/mocks/notifiers.ts +36 -0
  94. package/src/mocks/sendgrid.ts +57 -0
  95. package/src/mocks/twilio.ts +143 -0
  96. package/src/preload/registerBackendPreload.ts +4 -1
  97. package/src/time/freezeTime.ts +61 -0
  98. package/src/transaction/testTransaction.ts +456 -124
  99. package/src/utils/waitUntil.ts +47 -0
  100. package/biome.jsonc +0 -20
  101. package/bunfig.toml +0 -16
  102. package/src/cache/mongoTestCache.test.ts +0 -103
  103. package/src/env/setTerrenoTestEnv.test.ts +0 -26
  104. package/src/http/authAsUser.test.ts +0 -40
  105. package/src/http/getBaseServer.test.ts +0 -45
  106. package/src/logging/setupEnvironment.test.ts +0 -24
  107. package/src/logging/silenceLogs.test.ts +0 -52
  108. package/src/logging/testLogger.test.ts +0 -58
  109. package/src/mocks/sentryBun.test.ts +0 -230
  110. package/src/mongo/connection.test.ts +0 -43
  111. package/src/mongo/mongoServer.test.ts +0 -99
  112. package/src/preload/registerBackendPreload.test.ts +0 -10
  113. package/src/transaction/testTransaction.test.ts +0 -64
  114. package/src/utils/helpers.test.ts +0 -46
  115. package/tsconfig.json +0 -18
@@ -0,0 +1,456 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExpoModuleMocks = exports.createExpoGlobal = exports.VECTOR_ICON_FAMILIES = void 0;
4
+ const bun_test_1 = require("bun:test");
5
+ const luxon_1 = require("luxon");
6
+ const mockHelpers_1 = require("./mockHelpers");
7
+ /** Icon families mocked under `@expo/vector-icons` and `@expo/vector-icons/<Family>`. */
8
+ exports.VECTOR_ICON_FAMILIES = [
9
+ "AntDesign",
10
+ "Entypo",
11
+ "EvilIcons",
12
+ "Feather",
13
+ "FontAwesome",
14
+ "FontAwesome5",
15
+ "FontAwesome6",
16
+ "Fontisto",
17
+ "Foundation",
18
+ "Ionicons",
19
+ "MaterialCommunityIcons",
20
+ "MaterialIcons",
21
+ "Octicons",
22
+ "SimpleLineIcons",
23
+ "Zocial",
24
+ ];
25
+ const PERMISSION_STATUS = {
26
+ DENIED: "denied",
27
+ GRANTED: "granted",
28
+ UNDETERMINED: "undetermined",
29
+ };
30
+ const GRANTED_PERMISSION = { canAskAgain: true, expires: "never", granted: true, status: "granted" };
31
+ /** Event emitter stand-in for `expo-modules-core`'s `EventEmitter` and the classes built on it. */
32
+ class MockEventEmitter {
33
+ addListener;
34
+ emit;
35
+ listenerCount;
36
+ removeAllListeners;
37
+ removeListener;
38
+ removeSubscription;
39
+ constructor() {
40
+ this.addListener = (0, mockHelpers_1.stubSubscription)();
41
+ this.emit = (0, mockHelpers_1.stub)();
42
+ this.listenerCount = (0, mockHelpers_1.stubReturning)(0);
43
+ this.removeAllListeners = (0, mockHelpers_1.stub)();
44
+ this.removeListener = (0, mockHelpers_1.stub)();
45
+ this.removeSubscription = (0, mockHelpers_1.stub)();
46
+ }
47
+ }
48
+ class MockNativeModule extends MockEventEmitter {
49
+ }
50
+ class MockSharedObject extends MockEventEmitter {
51
+ }
52
+ class MockSharedRef extends MockSharedObject {
53
+ }
54
+ /** The `globalThis.expo` object `expo-modules-core` reads when it loads. */
55
+ const createExpoGlobal = () => ({
56
+ EventEmitter: MockEventEmitter,
57
+ modules: {},
58
+ NativeModule: MockNativeModule,
59
+ SharedObject: MockSharedObject,
60
+ SharedRef: MockSharedRef,
61
+ });
62
+ exports.createExpoGlobal = createExpoGlobal;
63
+ class CodedError extends Error {
64
+ code;
65
+ constructor(code, message) {
66
+ super(message);
67
+ this.code = code;
68
+ }
69
+ }
70
+ class UnavailabilityError extends CodedError {
71
+ constructor(moduleName, propertyName) {
72
+ super("ERR_UNAVAILABLE", `${moduleName}.${propertyName} is not available in tests`);
73
+ }
74
+ }
75
+ /** A `createPermissionHook` stand-in: the hook reports a granted permission. */
76
+ const createPermissionHook = (0, bun_test_1.mock)(() => (0, bun_test_1.mock)(() => [
77
+ GRANTED_PERMISSION,
78
+ (0, mockHelpers_1.stubResolving)(GRANTED_PERMISSION),
79
+ (0, mockHelpers_1.stubResolving)(GRANTED_PERMISSION),
80
+ ]));
81
+ /** Exports `expo` and `expo-modules-core` share: native module loaders return empty objects. */
82
+ const createNativeModuleCore = (platform) => ({
83
+ CodedError,
84
+ createPermissionHook,
85
+ EventEmitter: MockEventEmitter,
86
+ LegacyEventEmitter: MockEventEmitter,
87
+ NativeModule: MockNativeModule,
88
+ NativeModulesProxy: {},
89
+ PermissionStatus: PERMISSION_STATUS,
90
+ Platform: {
91
+ OS: platform,
92
+ select: (spec) => spec[platform] ?? spec.default,
93
+ },
94
+ registerWebModule: (0, bun_test_1.mock)((moduleClass) => moduleClass),
95
+ reloadAppAsync: (0, mockHelpers_1.stubResolving)(undefined),
96
+ requireNativeModule: (0, mockHelpers_1.stubReturning)({}),
97
+ requireNativeViewManager: (0, mockHelpers_1.stubReturning)((0, mockHelpers_1.hostComponent)("NativeView")),
98
+ requireOptionalNativeModule: (0, mockHelpers_1.stubReturning)(null),
99
+ SharedObject: MockSharedObject,
100
+ SharedRef: MockSharedRef,
101
+ UnavailabilityError,
102
+ useReleasingSharedObject: (0, bun_test_1.mock)((factory) => factory()),
103
+ uuid: { v4: (0, mockHelpers_1.stubReturning)("00000000-0000-4000-8000-000000000000") },
104
+ });
105
+ const createRouterMock = () => {
106
+ const createRouterHandle = () => ({
107
+ back: (0, mockHelpers_1.stub)(),
108
+ canDismiss: (0, mockHelpers_1.stubReturning)(false),
109
+ canGoBack: (0, mockHelpers_1.stubReturning)(true),
110
+ dismiss: (0, mockHelpers_1.stub)(),
111
+ dismissAll: (0, mockHelpers_1.stub)(),
112
+ dismissTo: (0, mockHelpers_1.stub)(),
113
+ navigate: (0, mockHelpers_1.stub)(),
114
+ prefetch: (0, mockHelpers_1.stub)(),
115
+ push: (0, mockHelpers_1.stub)(),
116
+ replace: (0, mockHelpers_1.stub)(),
117
+ setParams: (0, mockHelpers_1.stub)(),
118
+ });
119
+ const navigatorWithScreen = (name) => Object.assign((0, mockHelpers_1.hostComponent)(name), { Screen: (0, mockHelpers_1.hostComponent)(`${name}.Screen`) });
120
+ const Navigator = Object.assign((0, mockHelpers_1.hostComponent)("Navigator"), {
121
+ Slot: (0, mockHelpers_1.hostComponent)("Slot"),
122
+ useContext: (0, mockHelpers_1.stubReturning)({
123
+ descriptors: {},
124
+ navigation: {},
125
+ router: {},
126
+ state: { index: 0, routes: [] },
127
+ }),
128
+ });
129
+ const navigationFonts = {
130
+ bold: { fontFamily: "System", fontWeight: "600" },
131
+ heavy: { fontFamily: "System", fontWeight: "700" },
132
+ medium: { fontFamily: "System", fontWeight: "500" },
133
+ regular: { fontFamily: "System", fontWeight: "400" },
134
+ };
135
+ return {
136
+ DarkTheme: {
137
+ colors: {
138
+ background: "#010101",
139
+ border: "#272729",
140
+ card: "#121212",
141
+ notification: "#ff453a",
142
+ primary: "#0a84ff",
143
+ text: "#e5e5e7",
144
+ },
145
+ dark: true,
146
+ fonts: navigationFonts,
147
+ },
148
+ DefaultTheme: {
149
+ colors: {
150
+ background: "#f2f2f2",
151
+ border: "#d8d8d8",
152
+ card: "#ffffff",
153
+ notification: "#ff3b30",
154
+ primary: "#007aff",
155
+ text: "#1c1c1e",
156
+ },
157
+ dark: false,
158
+ fonts: navigationFonts,
159
+ },
160
+ Link: (0, mockHelpers_1.hostComponent)("Link"),
161
+ Navigator,
162
+ Redirect: (0, mockHelpers_1.hostComponent)("Redirect"),
163
+ router: createRouterHandle(),
164
+ Slot: (0, mockHelpers_1.hostComponent)("Slot"),
165
+ Stack: navigatorWithScreen("Stack"),
166
+ Tabs: navigatorWithScreen("Tabs"),
167
+ ThemeProvider: mockHelpers_1.passthroughComponent,
168
+ useFocusEffect: (0, bun_test_1.mock)((effect) => {
169
+ effect?.();
170
+ }),
171
+ useGlobalSearchParams: (0, mockHelpers_1.stubReturning)({}),
172
+ useLocalSearchParams: (0, mockHelpers_1.stubReturning)({}),
173
+ useNavigation: (0, bun_test_1.mock)(() => ({
174
+ addListener: (0, mockHelpers_1.stubReturning)((0, mockHelpers_1.stub)()),
175
+ canGoBack: (0, mockHelpers_1.stubReturning)(true),
176
+ dispatch: (0, mockHelpers_1.stub)(),
177
+ getParent: (0, mockHelpers_1.stubReturning)(undefined),
178
+ goBack: (0, mockHelpers_1.stub)(),
179
+ isFocused: (0, mockHelpers_1.stubReturning)(true),
180
+ navigate: (0, mockHelpers_1.stub)(),
181
+ setOptions: (0, mockHelpers_1.stub)(),
182
+ })),
183
+ useNavigationContainerRef: (0, mockHelpers_1.stubReturning)({ current: null }),
184
+ usePathname: (0, mockHelpers_1.stubReturning)("/"),
185
+ useRootNavigationState: (0, mockHelpers_1.stubReturning)({ key: "root" }),
186
+ useRouter: (0, bun_test_1.mock)(createRouterHandle),
187
+ useSearchParams: (0, mockHelpers_1.stubReturning)({}),
188
+ useSegments: (0, mockHelpers_1.stubReturning)([]),
189
+ };
190
+ };
191
+ const createVectorIconsMocks = () => {
192
+ const mocks = {};
193
+ const root = {};
194
+ for (const family of exports.VECTOR_ICON_FAMILIES) {
195
+ const Icon = Object.assign((0, mockHelpers_1.hostComponent)(family), {
196
+ getImageSource: (0, mockHelpers_1.stubResolving)(null),
197
+ glyphMap: {},
198
+ loadFont: (0, mockHelpers_1.stubResolving)(undefined),
199
+ });
200
+ root[family] = Icon;
201
+ mocks[`@expo/vector-icons/${family}`] = () => ({ default: Icon });
202
+ }
203
+ mocks["@expo/vector-icons"] = () => ({
204
+ ...root,
205
+ createIconSet: (0, mockHelpers_1.stubReturning)((0, mockHelpers_1.hostComponent)("Icon")),
206
+ });
207
+ return mocks;
208
+ };
209
+ /**
210
+ * Builds stand-ins for the Expo SDK modules most apps import: the `expo` / `expo-modules-core`
211
+ * native bridge, `expo-router`, `expo-constants`, `expo-linking`, `expo-font`, and the common
212
+ * device APIs. `expo-secure-store` lives in `authTokenStorage.ts`.
213
+ */
214
+ const createExpoModuleMocks = ({ expoConfig = { extra: {}, name: "test", slug: "test" }, locale = "en-US", platform = "ios", scheme, timeZone = "America/New_York", } = {}) => {
215
+ const linkingScheme = scheme ?? (typeof expoConfig.scheme === "string" ? expoConfig.scheme : "exp");
216
+ const [languageCode = "en", regionCode = "US"] = locale.split("-");
217
+ const core = createNativeModuleCore(platform);
218
+ const noopModule = () => ({});
219
+ return {
220
+ ...createVectorIconsMocks(),
221
+ expo: () => ({
222
+ ...core,
223
+ isRunningInExpoGo: (0, mockHelpers_1.stubReturning)(false),
224
+ registerRootComponent: (0, mockHelpers_1.stub)(),
225
+ useEvent: (0, mockHelpers_1.stubReturning)(undefined),
226
+ useEventListener: (0, mockHelpers_1.stub)(),
227
+ }),
228
+ "expo-application": () => ({
229
+ applicationId: "com.terreno.test",
230
+ applicationName: "test",
231
+ getInstallationTimeAsync: (0, mockHelpers_1.stubResolving)(luxon_1.DateTime.fromMillis(0).toJSDate()),
232
+ nativeApplicationVersion: "1.0.0",
233
+ nativeBuildVersion: "1",
234
+ }),
235
+ "expo-asset": () => ({
236
+ Asset: {
237
+ fromModule: (0, mockHelpers_1.stubReturning)({
238
+ downloadAsync: (0, mockHelpers_1.stubResolving)(undefined),
239
+ localUri: "test-asset",
240
+ uri: "test-asset",
241
+ }),
242
+ loadAsync: (0, mockHelpers_1.stubResolving)([]),
243
+ },
244
+ useAssets: (0, mockHelpers_1.stubReturning)([[], undefined]),
245
+ }),
246
+ "expo-clipboard": () => ({
247
+ getStringAsync: (0, mockHelpers_1.stubResolving)(""),
248
+ hasStringAsync: (0, mockHelpers_1.stubResolving)(false),
249
+ setImageAsync: (0, mockHelpers_1.stubResolving)(undefined),
250
+ setString: (0, mockHelpers_1.stub)(),
251
+ setStringAsync: (0, mockHelpers_1.stubResolving)(true),
252
+ }),
253
+ "expo-constants": () => {
254
+ const constants = {
255
+ appOwnership: null,
256
+ executionEnvironment: "bare",
257
+ expoConfig,
258
+ manifest: expoConfig,
259
+ platform: { [platform]: {} },
260
+ sessionId: "test-session",
261
+ statusBarHeight: 0,
262
+ };
263
+ return {
264
+ AppOwnership: { Expo: "expo" },
265
+ default: constants,
266
+ ExecutionEnvironment: { Bare: "bare", Standalone: "standalone", StoreClient: "storeClient" },
267
+ UserInterfaceIdiom: {
268
+ Desktop: "desktop",
269
+ Handset: "handset",
270
+ Tablet: "tablet",
271
+ TV: "tv",
272
+ Unsupported: "unsupported",
273
+ },
274
+ };
275
+ },
276
+ "expo-device": () => ({
277
+ brand: "Test",
278
+ DeviceType: { DESKTOP: 3, PHONE: 1, TABLET: 2, TV: 4, UNKNOWN: 0 },
279
+ deviceType: 1,
280
+ getDeviceTypeAsync: (0, mockHelpers_1.stubResolving)(1),
281
+ isDevice: false,
282
+ manufacturer: "Test",
283
+ modelName: "Test Device",
284
+ osName: platform === "android" ? "Android" : platform === "web" ? "Web" : "iOS",
285
+ osVersion: "1.0",
286
+ }),
287
+ "expo-file-system": () => ({
288
+ cacheDirectory: "file:///cache/",
289
+ deleteAsync: (0, mockHelpers_1.stubResolving)(undefined),
290
+ documentDirectory: "file:///documents/",
291
+ File: class File {
292
+ bytes = (0, mockHelpers_1.stubResolving)(new Uint8Array());
293
+ exists = false;
294
+ text = (0, mockHelpers_1.stubResolving)("");
295
+ uri;
296
+ constructor(...parts) {
297
+ this.uri = parts.map(String).join("/");
298
+ }
299
+ },
300
+ getInfoAsync: (0, mockHelpers_1.stubResolving)({ exists: false, isDirectory: false }),
301
+ readAsStringAsync: (0, mockHelpers_1.stubResolving)(""),
302
+ writeAsStringAsync: (0, mockHelpers_1.stubResolving)(undefined),
303
+ }),
304
+ "expo-font": () => ({
305
+ isLoaded: (0, mockHelpers_1.stubReturning)(true),
306
+ isLoading: (0, mockHelpers_1.stubReturning)(false),
307
+ loadAsync: (0, mockHelpers_1.stubResolving)(undefined),
308
+ useFonts: (0, mockHelpers_1.stubReturning)([true, null]),
309
+ }),
310
+ "expo-haptics": () => ({
311
+ ImpactFeedbackStyle: {
312
+ Heavy: "heavy",
313
+ Light: "light",
314
+ Medium: "medium",
315
+ Rigid: "rigid",
316
+ Soft: "soft",
317
+ },
318
+ impactAsync: (0, mockHelpers_1.stubResolving)(undefined),
319
+ NotificationFeedbackType: { Error: "error", Success: "success", Warning: "warning" },
320
+ notificationAsync: (0, mockHelpers_1.stubResolving)(undefined),
321
+ selectionAsync: (0, mockHelpers_1.stubResolving)(undefined),
322
+ }),
323
+ "expo-image-manipulator": () => ({
324
+ ImageManipulator: {
325
+ manipulate: (0, mockHelpers_1.stubReturning)({
326
+ renderAsync: (0, mockHelpers_1.stubResolving)({ saveAsync: (0, mockHelpers_1.stubResolving)({ height: 0, uri: "", width: 0 }) }),
327
+ }),
328
+ },
329
+ manipulateAsync: (0, mockHelpers_1.stubResolving)({ height: 0, uri: "", width: 0 }),
330
+ SaveFormat: { JPEG: "jpeg", PNG: "png", WEBP: "webp" },
331
+ }),
332
+ "expo-image-picker": () => ({
333
+ launchCameraAsync: (0, mockHelpers_1.stubResolving)({ assets: null, canceled: true }),
334
+ launchImageLibraryAsync: (0, mockHelpers_1.stubResolving)({ assets: null, canceled: true }),
335
+ MediaTypeOptions: { All: "All", Images: "Images", Videos: "Videos" },
336
+ PermissionStatus: PERMISSION_STATUS,
337
+ requestCameraPermissionsAsync: (0, mockHelpers_1.stubResolving)(GRANTED_PERMISSION),
338
+ requestMediaLibraryPermissionsAsync: (0, mockHelpers_1.stubResolving)(GRANTED_PERMISSION),
339
+ useCameraPermissions: createPermissionHook(),
340
+ useMediaLibraryPermissions: createPermissionHook(),
341
+ }),
342
+ "expo-linear-gradient": () => ({ LinearGradient: (0, mockHelpers_1.hostComponent)("LinearGradient") }),
343
+ "expo-linking": () => {
344
+ const createURL = (0, bun_test_1.mock)((path = "", options) => {
345
+ const query = new URLSearchParams(options?.queryParams ?? {}).toString();
346
+ return `${linkingScheme}://${path.replace(/^\//u, "")}${query ? `?${query}` : ""}`;
347
+ });
348
+ return {
349
+ addEventListener: (0, mockHelpers_1.stubSubscription)(),
350
+ canOpenURL: (0, mockHelpers_1.stubResolving)(true),
351
+ createURL,
352
+ getInitialURL: (0, mockHelpers_1.stubResolving)(null),
353
+ getLinkingURL: (0, mockHelpers_1.stubReturning)(null),
354
+ openSettings: (0, mockHelpers_1.stubResolving)(undefined),
355
+ openURL: (0, mockHelpers_1.stubResolving)(true),
356
+ parse: (0, bun_test_1.mock)((url) => ({
357
+ hostname: null,
358
+ path: url,
359
+ queryParams: {},
360
+ scheme: linkingScheme,
361
+ })),
362
+ parseInitialURLAsync: (0, mockHelpers_1.stubResolving)({
363
+ hostname: null,
364
+ path: null,
365
+ queryParams: {},
366
+ scheme: null,
367
+ }),
368
+ resolveScheme: (0, mockHelpers_1.stubReturning)(linkingScheme),
369
+ useLinkingURL: (0, mockHelpers_1.stubReturning)(null),
370
+ useURL: (0, mockHelpers_1.stubReturning)(null),
371
+ };
372
+ },
373
+ "expo-localization": () => ({
374
+ getCalendars: (0, mockHelpers_1.stubReturning)([
375
+ { calendar: "gregorian", firstWeekday: 1, timeZone, uses24hourClock: false },
376
+ ]),
377
+ getLocales: (0, mockHelpers_1.stubReturning)([
378
+ {
379
+ currencyCode: "USD",
380
+ decimalSeparator: ".",
381
+ digitGroupingSeparator: ",",
382
+ languageCode,
383
+ languageTag: locale,
384
+ measurementSystem: "us",
385
+ regionCode,
386
+ temperatureUnit: "fahrenheit",
387
+ textDirection: "ltr",
388
+ },
389
+ ]),
390
+ locale,
391
+ locales: [locale],
392
+ timezone: timeZone,
393
+ useCalendars: (0, mockHelpers_1.stubReturning)([
394
+ { calendar: "gregorian", firstWeekday: 1, timeZone, uses24hourClock: false },
395
+ ]),
396
+ useLocales: (0, mockHelpers_1.stubReturning)([{ languageCode, languageTag: locale, regionCode }]),
397
+ }),
398
+ "expo-modules-core": () => core,
399
+ "expo-modules-core/src/Refs": () => ({ createRef: (0, mockHelpers_1.stubReturning)({ current: null }) }),
400
+ "expo-modules-core/src/uuid/uuid.web": () => ({
401
+ uuid4: (0, mockHelpers_1.stubReturning)("00000000-0000-4000-8000-000000000000"),
402
+ }),
403
+ "expo-modules-core/src/web/index.web": () => ({ EventEmitter: MockEventEmitter }),
404
+ "expo-network": () => ({
405
+ addNetworkStateListener: (0, mockHelpers_1.stubSubscription)(),
406
+ getNetworkStateAsync: (0, mockHelpers_1.stubResolving)({
407
+ isConnected: true,
408
+ isInternetReachable: true,
409
+ type: "WIFI",
410
+ }),
411
+ NetworkStateType: { CELLULAR: "CELLULAR", NONE: "NONE", UNKNOWN: "UNKNOWN", WIFI: "WIFI" },
412
+ useNetworkState: (0, mockHelpers_1.stubReturning)({ isConnected: true, isInternetReachable: true, type: "WIFI" }),
413
+ }),
414
+ "expo-router": createRouterMock,
415
+ "expo-splash-screen": () => ({
416
+ hide: (0, mockHelpers_1.stub)(),
417
+ hideAsync: (0, mockHelpers_1.stubResolving)(true),
418
+ preventAutoHideAsync: (0, mockHelpers_1.stubResolving)(true),
419
+ setOptions: (0, mockHelpers_1.stub)(),
420
+ }),
421
+ "expo-status-bar": () => ({
422
+ StatusBar: (0, mockHelpers_1.hostComponent)("ExpoStatusBar"),
423
+ setStatusBarStyle: (0, mockHelpers_1.stub)(),
424
+ }),
425
+ "expo-updates": () => ({
426
+ channel: "test",
427
+ checkForUpdateAsync: (0, mockHelpers_1.stubResolving)({ isAvailable: false }),
428
+ fetchUpdateAsync: (0, mockHelpers_1.stubResolving)({ isNew: false }),
429
+ isEnabled: false,
430
+ reloadAsync: (0, mockHelpers_1.stubResolving)(undefined),
431
+ updateId: null,
432
+ useUpdates: (0, mockHelpers_1.stubReturning)({ isUpdateAvailable: false, isUpdatePending: false }),
433
+ }),
434
+ "expo-web-browser": () => ({
435
+ dismissBrowser: (0, mockHelpers_1.stub)(),
436
+ maybeCompleteAuthSession: (0, mockHelpers_1.stubReturning)({ type: "failed" }),
437
+ openAuthSessionAsync: (0, mockHelpers_1.stubResolving)({ type: "cancel" }),
438
+ openBrowserAsync: (0, mockHelpers_1.stubResolving)({ type: "opened" }),
439
+ WebBrowserResultType: {
440
+ CANCEL: "cancel",
441
+ DISMISS: "dismiss",
442
+ LOCKED: "locked",
443
+ OPENED: "opened",
444
+ },
445
+ }),
446
+ "expo/src/async-require/hmr": () => ({
447
+ default: { disable: (0, mockHelpers_1.stub)(), enable: (0, mockHelpers_1.stub)(), log: (0, mockHelpers_1.stub)(), setup: (0, mockHelpers_1.stub)() },
448
+ }),
449
+ "expo/src/async-require/messageSocket": noopModule,
450
+ "expo/src/async-require/setupHMR": noopModule,
451
+ // Expo's dev-only HMR client touches `window`/`document` when it loads.
452
+ "expo/src/Expo.fx": noopModule,
453
+ "expo/src/Expo.fx.tsx": noopModule,
454
+ };
455
+ };
456
+ exports.createExpoModuleMocks = createExpoModuleMocks;
@@ -0,0 +1,17 @@
1
+ import { type ModuleMockMap } from "./mockHelpers";
2
+ /** Network state `@react-native-community/netinfo` reports: online over Wi-Fi. */
3
+ export declare const MOCK_NET_INFO_STATE: {
4
+ readonly details: {};
5
+ readonly isConnected: true;
6
+ readonly isInternetReachable: true;
7
+ readonly isWifiEnabled: true;
8
+ readonly type: "wifi";
9
+ };
10
+ /** Linear interpolation clamped to the first/last range entries, like Reanimated's default. */
11
+ export declare const interpolate: (value: number, inputRange: readonly number[], outputRange: readonly number[]) => number;
12
+ /**
13
+ * Builds stand-ins for the native libraries most Expo apps depend on: Reanimated, Gesture
14
+ * Handler, SVG, safe-area-context, NetInfo, WebView, the community picker / slider /
15
+ * date-time picker, react-native-actions-sheet, pressto, and Sentry.
16
+ */
17
+ export declare const createLibraryModuleMocks: () => ModuleMockMap;