@terreno/ui 0.10.0 → 0.11.1
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.
- package/dist/Banner.js +7 -5
- package/dist/Banner.js.map +1 -1
- package/dist/Common.d.ts +3 -1
- package/dist/Common.js.map +1 -1
- package/dist/TextFieldNumberActionSheet.d.ts +1 -1
- package/dist/Toast.d.ts +1 -1
- package/dist/Toast.js +2 -2
- package/dist/Toast.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +2 -1
- package/src/ActionSheet.test.tsx +262 -3
- package/src/AddressField.test.tsx +50 -0
- package/src/Banner.test.tsx +65 -0
- package/src/Banner.tsx +7 -5
- package/src/Box.test.tsx +218 -0
- package/src/Button.test.tsx +71 -0
- package/src/Common.ts +3 -1
- package/src/ConsentFormScreen.test.tsx +167 -0
- package/src/ConsentNavigator.test.tsx +206 -0
- package/src/DecimalRangeActionSheet.test.tsx +53 -2
- package/src/EmailField.test.tsx +81 -0
- package/src/EmojiSelector.test.tsx +262 -1
- package/src/HeightActionSheet.test.tsx +57 -2
- package/src/InfoModalIcon.test.tsx +16 -0
- package/src/InfoTooltipButton.test.tsx +53 -1
- package/src/MobileAddressAutoComplete.test.tsx +137 -7
- package/src/Modal.test.tsx +188 -0
- package/src/NumberPickerActionSheet.test.tsx +59 -2
- package/src/Page.test.tsx +162 -1
- package/src/Pagination.test.tsx +16 -0
- package/src/PhoneNumberField.test.tsx +46 -9
- package/src/PickerSelect.test.tsx +230 -0
- package/src/SegmentedControl.test.tsx +38 -0
- package/src/SelectBadge.test.tsx +52 -1
- package/src/SideDrawer.test.tsx +69 -0
- package/src/Signature.test.tsx +42 -5
- package/src/SignatureField.test.tsx +35 -0
- package/src/Slider.test.tsx +59 -0
- package/src/Spinner.test.tsx +6 -0
- package/src/SplitPage.test.tsx +228 -2
- package/src/TapToEdit.test.tsx +171 -1
- package/src/TerrenoProvider.test.tsx +42 -2
- package/src/TextFieldNumberActionSheet.tsx +1 -1
- package/src/Theme.test.tsx +118 -28
- package/src/Toast.test.tsx +95 -2
- package/src/Toast.tsx +3 -3
- package/src/Tooltip.test.tsx +204 -1
- package/src/UnifiedAddressAutoComplete.test.tsx +38 -19
- package/src/UserInactivity.test.tsx +73 -1
- package/src/Utilities.test.tsx +190 -2
- package/src/WebAddressAutocomplete.test.tsx +148 -1
- package/src/__snapshots__/ActionSheet.test.tsx.snap +1736 -0
- package/src/__snapshots__/Button.test.tsx.snap +68 -0
- package/src/__snapshots__/EmojiSelector.test.tsx.snap +1363 -0
- package/src/__snapshots__/InfoTooltipButton.test.tsx.snap +72 -3
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +60 -9
- package/src/__snapshots__/Modal.test.tsx.snap +181 -0
- package/src/__snapshots__/Page.test.tsx.snap +48 -2
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +0 -93
- package/src/__snapshots__/PickerSelect.test.tsx.snap +706 -0
- package/src/__snapshots__/SideDrawer.test.tsx.snap +533 -1399
- package/src/__snapshots__/Signature.test.tsx.snap +0 -3
- package/src/__snapshots__/SplitPage.test.tsx.snap +970 -0
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +220 -4
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +93 -0
- package/src/bunSetup.ts +204 -121
- package/src/index.tsx +2 -2
- package/src/table/TableHeaderCell.test.tsx +142 -0
- package/src/table/TableRow.test.tsx +33 -0
- package/src/table/__snapshots__/TableRow.test.tsx.snap +403 -0
- package/src/table/tableContext.test.tsx +96 -0
- package/src/test-utils.tsx +1 -1
- package/src/useConsentForms.test.ts +130 -0
- package/src/useSubmitConsent.test.ts +64 -0
package/src/bunSetup.ts
CHANGED
|
@@ -1,46 +1,76 @@
|
|
|
1
1
|
import {beforeEach, mock} from "bun:test";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
+
type MockComponentProps = Record<string, unknown> & {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
style?: unknown;
|
|
7
|
+
testID?: string;
|
|
8
|
+
};
|
|
9
|
+
type MockStyleValue = unknown;
|
|
10
|
+
type MockAnimation = {
|
|
11
|
+
start?: (callback?: (result: {finished: boolean}) => void) => void;
|
|
12
|
+
stop?: () => void;
|
|
13
|
+
reset?: () => void;
|
|
14
|
+
};
|
|
15
|
+
type EasingFn = (t: number) => number;
|
|
16
|
+
type MockColor = string | number | null | undefined;
|
|
17
|
+
type MockAssetSource = {height?: number; uri?: string; width?: number} | null | undefined;
|
|
18
|
+
|
|
4
19
|
// Set environment variables
|
|
5
20
|
process.env.TZ = "America/New_York";
|
|
6
21
|
process.env.EXPO_OS = "ios";
|
|
7
22
|
|
|
8
23
|
// Define React Native globals
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
const rnGlobals = globalThis as typeof globalThis & {
|
|
25
|
+
__DEV__?: boolean;
|
|
26
|
+
__BUNDLE_START_TIME__?: number;
|
|
27
|
+
};
|
|
28
|
+
rnGlobals.__DEV__ = true;
|
|
29
|
+
rnGlobals.__BUNDLE_START_TIME__ = Date.now();
|
|
11
30
|
|
|
12
31
|
// Mock react-native to avoid Flow type errors
|
|
13
32
|
mock.module("react-native", () => {
|
|
14
|
-
const View = ({children, style, testID, ...props}:
|
|
33
|
+
const View = ({children, style, testID, ...props}: MockComponentProps) =>
|
|
15
34
|
React.createElement("View", {style, testID, ...props}, children);
|
|
16
|
-
const Text = ({children, style, ...props}:
|
|
35
|
+
const Text = ({children, style, ...props}: MockComponentProps) =>
|
|
17
36
|
React.createElement("Text", {style, ...props}, children);
|
|
18
|
-
const TextInput = (props:
|
|
19
|
-
const TouchableOpacity = ({children, ...props}:
|
|
37
|
+
const TextInput = (props: MockComponentProps) => React.createElement("TextInput", props);
|
|
38
|
+
const TouchableOpacity = ({children, ...props}: MockComponentProps) =>
|
|
20
39
|
React.createElement("TouchableOpacity", props, children);
|
|
21
|
-
const Pressable = ({children, ...props}:
|
|
40
|
+
const Pressable = ({children, ...props}: MockComponentProps) =>
|
|
22
41
|
React.createElement("Pressable", props, children);
|
|
23
|
-
const ScrollView = ({children, ...props}:
|
|
42
|
+
const ScrollView = ({children, ...props}: MockComponentProps) =>
|
|
24
43
|
React.createElement("ScrollView", props, children);
|
|
25
|
-
const Image = (props:
|
|
26
|
-
const ImageBackground = ({children, ...props}:
|
|
44
|
+
const Image = (props: MockComponentProps) => React.createElement("Image", props);
|
|
45
|
+
const ImageBackground = ({children, ...props}: MockComponentProps) =>
|
|
27
46
|
React.createElement("ImageBackground", props, children);
|
|
28
|
-
const ActivityIndicator = (props:
|
|
29
|
-
|
|
47
|
+
const ActivityIndicator = (props: MockComponentProps) =>
|
|
48
|
+
React.createElement("ActivityIndicator", props);
|
|
49
|
+
const FlatList = ({
|
|
50
|
+
data,
|
|
51
|
+
renderItem,
|
|
52
|
+
keyExtractor,
|
|
53
|
+
...props
|
|
54
|
+
}: MockComponentProps & {
|
|
55
|
+
data?: unknown[];
|
|
56
|
+
renderItem?: (info: {item: unknown; index: number; separators: unknown}) => React.ReactNode;
|
|
57
|
+
keyExtractor?: (item: unknown, index: number) => string;
|
|
58
|
+
}) =>
|
|
30
59
|
React.createElement(
|
|
31
60
|
"FlatList",
|
|
32
61
|
props,
|
|
33
|
-
data?.map((item:
|
|
34
|
-
renderItem({index, item, separators: {highlight: () => {}, unhighlight: () => {}}})
|
|
62
|
+
data?.map((item: unknown, index: number) =>
|
|
63
|
+
renderItem?.({index, item, separators: {highlight: () => {}, unhighlight: () => {}}})
|
|
35
64
|
)
|
|
36
65
|
);
|
|
37
|
-
const SectionList = (props:
|
|
38
|
-
const KeyboardAvoidingView = ({children, ...props}:
|
|
66
|
+
const SectionList = (props: MockComponentProps) => React.createElement("SectionList", props);
|
|
67
|
+
const KeyboardAvoidingView = ({children, ...props}: MockComponentProps) =>
|
|
39
68
|
React.createElement("KeyboardAvoidingView", props, children);
|
|
40
|
-
const SafeAreaView = ({children, ...props}:
|
|
69
|
+
const SafeAreaView = ({children, ...props}: MockComponentProps) =>
|
|
41
70
|
React.createElement("SafeAreaView", props, children);
|
|
42
|
-
const Modal = ({children, ...props}:
|
|
43
|
-
|
|
71
|
+
const Modal = ({children, ...props}: MockComponentProps) =>
|
|
72
|
+
React.createElement("Modal", props, children);
|
|
73
|
+
const Switch = (props: MockComponentProps) => React.createElement("Switch", props);
|
|
44
74
|
const AnimatedValue = class Value {
|
|
45
75
|
_value: number;
|
|
46
76
|
constructor(value: number = 0) {
|
|
@@ -63,8 +93,8 @@ mock.module("react-native", () => {
|
|
|
63
93
|
track = mock(() => {});
|
|
64
94
|
};
|
|
65
95
|
const AnimatedValueXY = class ValueXY {
|
|
66
|
-
x:
|
|
67
|
-
y:
|
|
96
|
+
x: InstanceType<typeof AnimatedValue>;
|
|
97
|
+
y: InstanceType<typeof AnimatedValue>;
|
|
68
98
|
constructor(value?: {x?: number; y?: number}) {
|
|
69
99
|
this.x = new AnimatedValue(value?.x || 0);
|
|
70
100
|
this.y = new AnimatedValue(value?.y || 0);
|
|
@@ -89,7 +119,7 @@ mock.module("react-native", () => {
|
|
|
89
119
|
const Animated = {
|
|
90
120
|
// Operators
|
|
91
121
|
add: mock(() => new AnimatedValue(0)),
|
|
92
|
-
createAnimatedComponent: (comp:
|
|
122
|
+
createAnimatedComponent: <T>(comp: T): T => comp,
|
|
93
123
|
decay: mock(() => createAnimationMock()),
|
|
94
124
|
delay: mock(() => createAnimationMock()),
|
|
95
125
|
diffClamp: mock(() => new AnimatedValue(0)),
|
|
@@ -98,7 +128,7 @@ mock.module("react-native", () => {
|
|
|
98
128
|
event: mock(() => mock(() => {})),
|
|
99
129
|
FlatList,
|
|
100
130
|
Image,
|
|
101
|
-
loop: mock((animation:
|
|
131
|
+
loop: mock((animation: MockAnimation) => ({
|
|
102
132
|
reset: mock(() => {}),
|
|
103
133
|
start: mock((callback?: (result: {finished: boolean}) => void) => {
|
|
104
134
|
animation?.start?.();
|
|
@@ -109,10 +139,10 @@ mock.module("react-native", () => {
|
|
|
109
139
|
modulo: mock(() => new AnimatedValue(0)),
|
|
110
140
|
multiply: mock(() => new AnimatedValue(0)),
|
|
111
141
|
// Composition functions
|
|
112
|
-
parallel: mock((animations:
|
|
142
|
+
parallel: mock((animations: MockAnimation[]) => ({
|
|
113
143
|
reset: mock(() => {}),
|
|
114
144
|
start: mock((callback?: (result: {finished: boolean}) => void) => {
|
|
115
|
-
animations?.forEach((anim:
|
|
145
|
+
animations?.forEach((anim: MockAnimation) => {
|
|
116
146
|
anim?.start?.();
|
|
117
147
|
});
|
|
118
148
|
callback?.({finished: true});
|
|
@@ -120,10 +150,10 @@ mock.module("react-native", () => {
|
|
|
120
150
|
stop: mock(() => {}),
|
|
121
151
|
})),
|
|
122
152
|
ScrollView,
|
|
123
|
-
sequence: mock((animations:
|
|
153
|
+
sequence: mock((animations: MockAnimation[]) => ({
|
|
124
154
|
reset: mock(() => {}),
|
|
125
155
|
start: mock((callback?: (result: {finished: boolean}) => void) => {
|
|
126
|
-
animations?.forEach((anim:
|
|
156
|
+
animations?.forEach((anim: MockAnimation) => {
|
|
127
157
|
anim?.start?.();
|
|
128
158
|
});
|
|
129
159
|
callback?.({finished: true});
|
|
@@ -131,10 +161,10 @@ mock.module("react-native", () => {
|
|
|
131
161
|
stop: mock(() => {}),
|
|
132
162
|
})),
|
|
133
163
|
spring: mock(() => createAnimationMock()),
|
|
134
|
-
stagger: mock((_delay: number, animations:
|
|
164
|
+
stagger: mock((_delay: number, animations: MockAnimation[]) => ({
|
|
135
165
|
reset: mock(() => {}),
|
|
136
166
|
start: mock((callback?: (result: {finished: boolean}) => void) => {
|
|
137
|
-
animations?.forEach((anim:
|
|
167
|
+
animations?.forEach((anim: MockAnimation) => {
|
|
138
168
|
anim?.start?.();
|
|
139
169
|
});
|
|
140
170
|
callback?.({finished: true});
|
|
@@ -153,13 +183,14 @@ mock.module("react-native", () => {
|
|
|
153
183
|
const StyleSheet = {
|
|
154
184
|
absoluteFill: {bottom: 0, left: 0, position: "absolute", right: 0, top: 0},
|
|
155
185
|
absoluteFillObject: {bottom: 0, left: 0, position: "absolute", right: 0, top: 0},
|
|
156
|
-
create: (styles:
|
|
157
|
-
flatten: (style:
|
|
186
|
+
create: <T>(styles: T): T => styles,
|
|
187
|
+
flatten: (style: MockStyleValue) =>
|
|
188
|
+
Array.isArray(style) ? Object.assign({}, ...style) : style || {},
|
|
158
189
|
hairlineWidth: 1,
|
|
159
190
|
};
|
|
160
191
|
const Platform = {
|
|
161
192
|
OS: "ios",
|
|
162
|
-
select: (obj:
|
|
193
|
+
select: <T>(obj: {ios?: T; default?: T}): T | undefined => obj.ios ?? obj.default,
|
|
163
194
|
Version: "14.0",
|
|
164
195
|
};
|
|
165
196
|
const Dimensions = {
|
|
@@ -237,11 +268,11 @@ mock.module("react-native", () => {
|
|
|
237
268
|
addEventListener: mock(() => ({remove: mock(() => {})})),
|
|
238
269
|
exitApp: mock(() => {}),
|
|
239
270
|
};
|
|
240
|
-
const TouchableWithoutFeedback = ({children, ...props}:
|
|
271
|
+
const TouchableWithoutFeedback = ({children, ...props}: MockComponentProps) =>
|
|
241
272
|
React.createElement("TouchableWithoutFeedback", props, children);
|
|
242
|
-
const TouchableHighlight = ({children, ...props}:
|
|
273
|
+
const TouchableHighlight = ({children, ...props}: MockComponentProps) =>
|
|
243
274
|
React.createElement("TouchableHighlight", props, children);
|
|
244
|
-
const TouchableNativeFeedback = ({children, ...props}:
|
|
275
|
+
const TouchableNativeFeedback = ({children, ...props}: MockComponentProps) =>
|
|
245
276
|
React.createElement("TouchableNativeFeedback", props, children);
|
|
246
277
|
const Touchable = {
|
|
247
278
|
Mixin: {
|
|
@@ -304,10 +335,10 @@ mock.module("react-native", () => {
|
|
|
304
335
|
ease: mock((t: number) => t),
|
|
305
336
|
elastic: mock(() => (t: number) => t),
|
|
306
337
|
exp: mock((t: number) => t),
|
|
307
|
-
in: mock((f:
|
|
308
|
-
inOut: mock((f:
|
|
338
|
+
in: mock((f: EasingFn) => f),
|
|
339
|
+
inOut: mock((f: EasingFn) => f),
|
|
309
340
|
linear: mock((t: number) => t),
|
|
310
|
-
out: mock((f:
|
|
341
|
+
out: mock((f: EasingFn) => f),
|
|
311
342
|
poly: mock(() => (t: number) => t),
|
|
312
343
|
quad: mock((t: number) => t * t),
|
|
313
344
|
sin: mock((t: number) => Math.sin(t)),
|
|
@@ -429,12 +460,16 @@ if (typeof globalThis.expo === "undefined") {
|
|
|
429
460
|
EventEmitter: EventEmitterClass,
|
|
430
461
|
NativeModule: class NativeModule {},
|
|
431
462
|
SharedObject: class SharedObject {},
|
|
432
|
-
|
|
463
|
+
// noExplicitAny: globalThis.expo is typed by expo-modules-core with many native-only APIs
|
|
464
|
+
// that aren't needed for these mocks, so we cast through unknown to satisfy the type.
|
|
465
|
+
} as unknown as typeof globalThis.expo;
|
|
433
466
|
}
|
|
434
467
|
|
|
435
468
|
// Mock expo-router
|
|
436
469
|
mock.module("expo-router", () => ({
|
|
437
|
-
Link: ({children, ...props}:
|
|
470
|
+
Link: ({children, ...props}: MockComponentProps) => React.createElement("Link", props, children),
|
|
471
|
+
Navigator: ({children, ...props}: MockComponentProps) =>
|
|
472
|
+
React.createElement("Navigator", props, children),
|
|
438
473
|
router: {
|
|
439
474
|
back: mock(() => {}),
|
|
440
475
|
canGoBack: mock(() => true),
|
|
@@ -442,9 +477,19 @@ mock.module("expo-router", () => ({
|
|
|
442
477
|
push: mock(() => {}),
|
|
443
478
|
replace: mock(() => {}),
|
|
444
479
|
},
|
|
445
|
-
|
|
446
|
-
|
|
480
|
+
Slot: ({children, ...props}: MockComponentProps) => React.createElement("Slot", props, children),
|
|
481
|
+
Stack: ({children, ...props}: MockComponentProps) =>
|
|
482
|
+
React.createElement("Stack", props, children),
|
|
483
|
+
Tabs: ({children, ...props}: MockComponentProps) => React.createElement("Tabs", props, children),
|
|
484
|
+
useFocusEffect: mock(() => undefined),
|
|
447
485
|
useLocalSearchParams: mock(() => ({})),
|
|
486
|
+
useNavigation: mock(() => ({
|
|
487
|
+
addListener: mock(() => () => undefined),
|
|
488
|
+
goBack: mock(() => {}),
|
|
489
|
+
navigate: mock(() => {}),
|
|
490
|
+
setOptions: mock(() => {}),
|
|
491
|
+
})),
|
|
492
|
+
usePathname: mock(() => "/"),
|
|
448
493
|
useRouter: mock(() => ({
|
|
449
494
|
back: mock(() => {}),
|
|
450
495
|
canGoBack: mock(() => true),
|
|
@@ -452,6 +497,7 @@ mock.module("expo-router", () => ({
|
|
|
452
497
|
push: mock(() => {}),
|
|
453
498
|
replace: mock(() => {}),
|
|
454
499
|
})),
|
|
500
|
+
useSearchParams: mock(() => ({})),
|
|
455
501
|
useSegments: mock(() => []),
|
|
456
502
|
}));
|
|
457
503
|
|
|
@@ -630,7 +676,7 @@ mock.module("@expo/vector-icons/FontAwesome6", () => ({
|
|
|
630
676
|
|
|
631
677
|
// Mock linkify-it - need to mock the Hyperlink component directly instead
|
|
632
678
|
mock.module("./Hyperlink", () => ({
|
|
633
|
-
Hyperlink: ({children}:
|
|
679
|
+
Hyperlink: ({children}: MockComponentProps) => React.createElement("View", {}, children),
|
|
634
680
|
}));
|
|
635
681
|
|
|
636
682
|
// Mock react-native internal modules with Flow types
|
|
@@ -638,7 +684,7 @@ mock.module("./Hyperlink", () => ({
|
|
|
638
684
|
|
|
639
685
|
// StyleSheet related
|
|
640
686
|
mock.module("react-native/Libraries/StyleSheet/processColor", () => {
|
|
641
|
-
const processColor = (color:
|
|
687
|
+
const processColor = (color: MockColor) => {
|
|
642
688
|
if (color === null || color === undefined) return null;
|
|
643
689
|
if (typeof color === "number") return color;
|
|
644
690
|
return 0xff000000;
|
|
@@ -647,7 +693,7 @@ mock.module("react-native/Libraries/StyleSheet/processColor", () => {
|
|
|
647
693
|
});
|
|
648
694
|
|
|
649
695
|
mock.module("react-native/Libraries/StyleSheet/normalizeColor", () => {
|
|
650
|
-
const normalizeColor = (color:
|
|
696
|
+
const normalizeColor = (color: MockColor) => {
|
|
651
697
|
if (color === null || color === undefined) return null;
|
|
652
698
|
if (typeof color === "number") return color;
|
|
653
699
|
return 0xff000000;
|
|
@@ -656,24 +702,26 @@ mock.module("react-native/Libraries/StyleSheet/normalizeColor", () => {
|
|
|
656
702
|
});
|
|
657
703
|
|
|
658
704
|
mock.module("react-native/Libraries/StyleSheet/PlatformColorValueTypes", () => ({
|
|
659
|
-
DynamicColorIOS: (obj:
|
|
660
|
-
normalizeColorObject: (color:
|
|
661
|
-
PlatformColor: (...args:
|
|
662
|
-
processColorObject: (color:
|
|
705
|
+
DynamicColorIOS: (obj: {light: unknown}) => obj.light,
|
|
706
|
+
normalizeColorObject: (color: MockColor) => color,
|
|
707
|
+
PlatformColor: (...args: unknown[]) => args[0],
|
|
708
|
+
processColorObject: (color: MockColor) => color,
|
|
663
709
|
}));
|
|
664
710
|
|
|
665
711
|
mock.module("react-native/Libraries/StyleSheet/StyleSheet", () => ({
|
|
666
712
|
absoluteFill: {bottom: 0, left: 0, position: "absolute", right: 0, top: 0},
|
|
667
713
|
absoluteFillObject: {bottom: 0, left: 0, position: "absolute", right: 0, top: 0},
|
|
668
|
-
create: (styles:
|
|
714
|
+
create: <T>(styles: T): T => styles,
|
|
669
715
|
default: {
|
|
670
716
|
absoluteFill: {bottom: 0, left: 0, position: "absolute", right: 0, top: 0},
|
|
671
717
|
absoluteFillObject: {bottom: 0, left: 0, position: "absolute", right: 0, top: 0},
|
|
672
|
-
create: (styles:
|
|
673
|
-
flatten: (style:
|
|
718
|
+
create: <T>(styles: T): T => styles,
|
|
719
|
+
flatten: (style: MockStyleValue) =>
|
|
720
|
+
Array.isArray(style) ? Object.assign({}, ...style) : style || {},
|
|
674
721
|
hairlineWidth: 1,
|
|
675
722
|
},
|
|
676
|
-
flatten: (style:
|
|
723
|
+
flatten: (style: MockStyleValue) =>
|
|
724
|
+
Array.isArray(style) ? Object.assign({}, ...style) : style || {},
|
|
677
725
|
hairlineWidth: 1,
|
|
678
726
|
}));
|
|
679
727
|
|
|
@@ -685,7 +733,7 @@ mock.module("react-native/Libraries/NativeComponent/NativeComponentRegistry", ()
|
|
|
685
733
|
}));
|
|
686
734
|
|
|
687
735
|
mock.module("react-native/Libraries/NativeComponent/ViewConfigIgnore", () => ({
|
|
688
|
-
ConditionallyIgnoredEventHandlers: (handlers:
|
|
736
|
+
ConditionallyIgnoredEventHandlers: <T>(handlers: T): T => handlers,
|
|
689
737
|
DifferentHeuristics: {},
|
|
690
738
|
ignoredViewConfigPropNames: new Set(),
|
|
691
739
|
isIgnoredViewConfigProp: mock(() => false),
|
|
@@ -693,14 +741,15 @@ mock.module("react-native/Libraries/NativeComponent/ViewConfigIgnore", () => ({
|
|
|
693
741
|
|
|
694
742
|
// Mock @react-native-community/slider
|
|
695
743
|
mock.module("@react-native-community/slider", () => ({
|
|
696
|
-
default: (props:
|
|
697
|
-
Slider: (props:
|
|
744
|
+
default: (props: MockComponentProps) => React.createElement("Slider", props),
|
|
745
|
+
Slider: (props: MockComponentProps) => React.createElement("Slider", props),
|
|
698
746
|
}));
|
|
699
747
|
|
|
700
748
|
// Mock react-native-swiper-flatlist
|
|
701
749
|
mock.module("react-native-swiper-flatlist", () => ({
|
|
702
|
-
default: ({children, ...props}:
|
|
703
|
-
|
|
750
|
+
default: ({children, ...props}: MockComponentProps) =>
|
|
751
|
+
React.createElement("SwiperFlatList", props, children),
|
|
752
|
+
SwiperFlatList: ({children, ...props}: MockComponentProps) =>
|
|
704
753
|
React.createElement("SwiperFlatList", props, children),
|
|
705
754
|
}));
|
|
706
755
|
|
|
@@ -746,7 +795,7 @@ mock.module("react-native/Libraries/Utilities/codegenNativeCommands", () => ({
|
|
|
746
795
|
|
|
747
796
|
// Image related
|
|
748
797
|
mock.module("react-native/Libraries/Image/resolveAssetSource", () => {
|
|
749
|
-
const resolveAssetSource = (source:
|
|
798
|
+
const resolveAssetSource = (source: MockAssetSource) => ({
|
|
750
799
|
height: source?.height || 0,
|
|
751
800
|
scale: 1,
|
|
752
801
|
uri: source?.uri || "",
|
|
@@ -768,13 +817,22 @@ mock.module("react-native/Libraries/Image/ImageSource", () => ({
|
|
|
768
817
|
|
|
769
818
|
// Animated related
|
|
770
819
|
mock.module("react-native/Libraries/Animated/Animated", () => {
|
|
771
|
-
const View = ({children, style}:
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
|
|
820
|
+
const View = ({children, style}: MockComponentProps) =>
|
|
821
|
+
React.createElement("View", {style}, children);
|
|
822
|
+
const Text = ({children, style}: MockComponentProps) =>
|
|
823
|
+
React.createElement("Text", {style}, children);
|
|
824
|
+
const Image = (props: MockComponentProps) => React.createElement("Image", props);
|
|
825
|
+
const ScrollView = ({children}: MockComponentProps) =>
|
|
826
|
+
React.createElement("ScrollView", {}, children);
|
|
775
827
|
return {
|
|
776
|
-
createAnimatedComponent: (c:
|
|
777
|
-
default: {
|
|
828
|
+
createAnimatedComponent: <T>(c: T): T => c,
|
|
829
|
+
default: {
|
|
830
|
+
createAnimatedComponent: <T>(c: T): T => c,
|
|
831
|
+
Image,
|
|
832
|
+
ScrollView,
|
|
833
|
+
Text,
|
|
834
|
+
View,
|
|
835
|
+
},
|
|
778
836
|
Image,
|
|
779
837
|
ScrollView,
|
|
780
838
|
Text,
|
|
@@ -803,9 +861,13 @@ mock.module("react-native/Libraries/TurboModule/TurboModuleRegistry", () => ({
|
|
|
803
861
|
|
|
804
862
|
// Utilities
|
|
805
863
|
mock.module("react-native/Libraries/Utilities/Platform", () => ({
|
|
806
|
-
default: {
|
|
864
|
+
default: {
|
|
865
|
+
OS: "ios",
|
|
866
|
+
select: <T>(obj: {ios?: T; default?: T}): T | undefined => obj.ios ?? obj.default,
|
|
867
|
+
Version: "14.0",
|
|
868
|
+
},
|
|
807
869
|
OS: "ios",
|
|
808
|
-
select: (obj:
|
|
870
|
+
select: <T>(obj: {ios?: T; default?: T}): T | undefined => obj.ios ?? obj.default,
|
|
809
871
|
Version: "14.0",
|
|
810
872
|
}));
|
|
811
873
|
|
|
@@ -837,60 +899,71 @@ mock.module("react-native/Libraries/Utilities/useColorScheme", () => ({
|
|
|
837
899
|
|
|
838
900
|
// Components
|
|
839
901
|
mock.module("react-native/Libraries/Components/View/View", () => ({
|
|
840
|
-
default: ({children, style, testID, ...props}:
|
|
902
|
+
default: ({children, style, testID, ...props}: MockComponentProps) =>
|
|
841
903
|
React.createElement("View", {style, testID, ...props}, children),
|
|
842
904
|
}));
|
|
843
905
|
|
|
844
906
|
mock.module("react-native/Libraries/Text/Text", () => ({
|
|
845
|
-
default: ({children, style, ...props}:
|
|
907
|
+
default: ({children, style, ...props}: MockComponentProps) =>
|
|
846
908
|
React.createElement("Text", {style, ...props}, children),
|
|
847
909
|
}));
|
|
848
910
|
|
|
849
911
|
mock.module("react-native/Libraries/Components/TextInput/TextInput", () => ({
|
|
850
|
-
default: (props:
|
|
912
|
+
default: (props: MockComponentProps) => React.createElement("TextInput", props),
|
|
851
913
|
}));
|
|
852
914
|
|
|
853
915
|
mock.module("react-native/Libraries/Image/Image", () => ({
|
|
854
|
-
default: (props:
|
|
916
|
+
default: (props: MockComponentProps) => React.createElement("Image", props),
|
|
855
917
|
}));
|
|
856
918
|
|
|
857
919
|
mock.module("react-native/Libraries/Components/ScrollView/ScrollView", () => ({
|
|
858
|
-
default: ({children, ...props}:
|
|
920
|
+
default: ({children, ...props}: MockComponentProps) =>
|
|
921
|
+
React.createElement("ScrollView", props, children),
|
|
859
922
|
}));
|
|
860
923
|
|
|
861
924
|
mock.module("react-native/Libraries/Components/Pressable/Pressable", () => ({
|
|
862
|
-
default: ({children, ...props}:
|
|
925
|
+
default: ({children, ...props}: MockComponentProps) =>
|
|
926
|
+
React.createElement("Pressable", props, children),
|
|
863
927
|
}));
|
|
864
928
|
|
|
865
929
|
mock.module("react-native/Libraries/Components/Touchable/TouchableOpacity", () => ({
|
|
866
|
-
default: ({children, ...props}:
|
|
930
|
+
default: ({children, ...props}: MockComponentProps) =>
|
|
931
|
+
React.createElement("TouchableOpacity", props, children),
|
|
867
932
|
}));
|
|
868
933
|
|
|
869
934
|
mock.module("react-native/Libraries/Components/ActivityIndicator/ActivityIndicator", () => ({
|
|
870
|
-
default: (props:
|
|
935
|
+
default: (props: MockComponentProps) => React.createElement("ActivityIndicator", props),
|
|
871
936
|
}));
|
|
872
937
|
|
|
873
938
|
mock.module("react-native/Libraries/Modal/Modal", () => ({
|
|
874
|
-
default: ({children, ...props}:
|
|
939
|
+
default: ({children, ...props}: MockComponentProps) =>
|
|
940
|
+
React.createElement("Modal", props, children),
|
|
875
941
|
}));
|
|
876
942
|
|
|
877
943
|
mock.module("react-native/Libraries/Components/Switch/Switch", () => ({
|
|
878
|
-
default: (props:
|
|
944
|
+
default: (props: MockComponentProps) => React.createElement("Switch", props),
|
|
879
945
|
}));
|
|
880
946
|
|
|
881
947
|
mock.module("react-native/Libraries/Lists/FlatList", () => ({
|
|
882
|
-
default: ({
|
|
948
|
+
default: ({
|
|
949
|
+
data,
|
|
950
|
+
renderItem,
|
|
951
|
+
...props
|
|
952
|
+
}: MockComponentProps & {
|
|
953
|
+
data?: unknown[];
|
|
954
|
+
renderItem?: (info: {item: unknown; index: number; separators: unknown}) => React.ReactNode;
|
|
955
|
+
}) =>
|
|
883
956
|
React.createElement(
|
|
884
957
|
"FlatList",
|
|
885
958
|
props,
|
|
886
|
-
data?.map((item:
|
|
887
|
-
renderItem({index, item, separators: {highlight: () => {}, unhighlight: () => {}}})
|
|
959
|
+
data?.map((item: unknown, index: number) =>
|
|
960
|
+
renderItem?.({index, item, separators: {highlight: () => {}, unhighlight: () => {}}})
|
|
888
961
|
)
|
|
889
962
|
),
|
|
890
963
|
}));
|
|
891
964
|
|
|
892
965
|
mock.module("react-native/Libraries/Lists/SectionList", () => ({
|
|
893
|
-
default: (props:
|
|
966
|
+
default: (props: MockComponentProps) => React.createElement("SectionList", props),
|
|
894
967
|
}));
|
|
895
968
|
|
|
896
969
|
// APIs
|
|
@@ -1028,10 +1101,10 @@ mock.module("react-native/Libraries/Animated/Easing", () => ({
|
|
|
1028
1101
|
ease: (t: number) => t,
|
|
1029
1102
|
elastic: () => (t: number) => t,
|
|
1030
1103
|
exp: (t: number) => t,
|
|
1031
|
-
in: (f:
|
|
1032
|
-
inOut: (f:
|
|
1104
|
+
in: (f: EasingFn) => f,
|
|
1105
|
+
inOut: (f: EasingFn) => f,
|
|
1033
1106
|
linear: (t: number) => t,
|
|
1034
|
-
out: (f:
|
|
1107
|
+
out: (f: EasingFn) => f,
|
|
1035
1108
|
poly: () => (t: number) => t,
|
|
1036
1109
|
quad: (t: number) => t * t,
|
|
1037
1110
|
sin: (t: number) => Math.sin(t),
|
|
@@ -1097,10 +1170,13 @@ mock.module("react-native/Libraries/LogBox/LogBox", () => ({
|
|
|
1097
1170
|
}));
|
|
1098
1171
|
|
|
1099
1172
|
// Mock @react-native-picker/picker
|
|
1100
|
-
|
|
1173
|
+
type PickerItem = (p: MockComponentProps) => React.ReactElement;
|
|
1174
|
+
const PickerComponent = ({children, ...props}: MockComponentProps) =>
|
|
1101
1175
|
React.createElement("Picker", props, children);
|
|
1102
|
-
(PickerComponent as
|
|
1103
|
-
|
|
1176
|
+
(PickerComponent as typeof PickerComponent & {Item: PickerItem}).Item = ({
|
|
1177
|
+
children,
|
|
1178
|
+
...props
|
|
1179
|
+
}: MockComponentProps) => React.createElement("Picker.Item", props, children);
|
|
1104
1180
|
mock.module("@react-native-picker/picker", () => ({
|
|
1105
1181
|
Picker: PickerComponent,
|
|
1106
1182
|
PickerIOS: PickerComponent,
|
|
@@ -1108,7 +1184,8 @@ mock.module("@react-native-picker/picker", () => ({
|
|
|
1108
1184
|
|
|
1109
1185
|
// Mock react-native-picker-select
|
|
1110
1186
|
mock.module("react-native-picker-select", () => ({
|
|
1111
|
-
default: ({children, ...props}:
|
|
1187
|
+
default: ({children, ...props}: MockComponentProps) =>
|
|
1188
|
+
React.createElement("RNPickerSelect", props, children),
|
|
1112
1189
|
}));
|
|
1113
1190
|
|
|
1114
1191
|
// Mock @react-native-community/datetimepicker
|
|
@@ -1117,26 +1194,27 @@ mock.module("@react-native-community/datetimepicker", () => ({
|
|
|
1117
1194
|
dismiss: mock(() => Promise.resolve()),
|
|
1118
1195
|
open: mock(() => Promise.resolve({action: "dismissed"})),
|
|
1119
1196
|
},
|
|
1120
|
-
default: (props:
|
|
1197
|
+
default: (props: MockComponentProps) => React.createElement("DateTimePicker", props),
|
|
1121
1198
|
}));
|
|
1122
1199
|
|
|
1123
1200
|
// Mock react-native-calendars
|
|
1124
1201
|
mock.module("react-native-calendars", () => ({
|
|
1125
|
-
Agenda: (props:
|
|
1126
|
-
AgendaList: (props:
|
|
1127
|
-
Calendar: (props:
|
|
1128
|
-
CalendarList: (props:
|
|
1129
|
-
ExpandableCalendar: (props:
|
|
1202
|
+
Agenda: (props: MockComponentProps) => React.createElement("Agenda", props),
|
|
1203
|
+
AgendaList: (props: MockComponentProps) => React.createElement("AgendaList", props),
|
|
1204
|
+
Calendar: (props: MockComponentProps) => React.createElement("Calendar", props),
|
|
1205
|
+
CalendarList: (props: MockComponentProps) => React.createElement("CalendarList", props),
|
|
1206
|
+
ExpandableCalendar: (props: MockComponentProps) =>
|
|
1207
|
+
React.createElement("ExpandableCalendar", props),
|
|
1130
1208
|
LocaleConfig: {
|
|
1131
1209
|
defaultLocale: "en",
|
|
1132
1210
|
locales: {},
|
|
1133
1211
|
},
|
|
1134
|
-
WeekCalendar: (props:
|
|
1212
|
+
WeekCalendar: (props: MockComponentProps) => React.createElement("WeekCalendar", props),
|
|
1135
1213
|
}));
|
|
1136
1214
|
|
|
1137
1215
|
// Mock more react-native internal modules with Flow types
|
|
1138
1216
|
mock.module("react-native/Libraries/Image/resolveAssetSource", () => ({
|
|
1139
|
-
default: mock((source:
|
|
1217
|
+
default: mock((source: MockAssetSource) => ({
|
|
1140
1218
|
height: source?.height || 0,
|
|
1141
1219
|
scale: 1,
|
|
1142
1220
|
uri: source?.uri || "",
|
|
@@ -1153,12 +1231,16 @@ mock.module("react-native/Libraries/Image/AssetSourceResolver", () => ({
|
|
|
1153
1231
|
|
|
1154
1232
|
// Mock react-native-gesture-handler
|
|
1155
1233
|
mock.module("react-native-gesture-handler", () => {
|
|
1156
|
-
const GestureHandler = ({children}:
|
|
1234
|
+
const GestureHandler = ({children}: MockComponentProps) => children;
|
|
1157
1235
|
|
|
1236
|
+
type ChainableGesture = {
|
|
1237
|
+
[method: string]: (...args: unknown[]) => ChainableGesture;
|
|
1238
|
+
};
|
|
1158
1239
|
// Create a chainable gesture object that returns itself for all method calls
|
|
1159
|
-
const createChainableGesture = ():
|
|
1160
|
-
const gesture
|
|
1240
|
+
const createChainableGesture = (): ChainableGesture => {
|
|
1241
|
+
const gesture = {} as ChainableGesture;
|
|
1161
1242
|
const chainableMethods = [
|
|
1243
|
+
"onBegin",
|
|
1162
1244
|
"onStart",
|
|
1163
1245
|
"onEnd",
|
|
1164
1246
|
"onUpdate",
|
|
@@ -1207,7 +1289,7 @@ mock.module("react-native-gesture-handler", () => {
|
|
|
1207
1289
|
return {
|
|
1208
1290
|
BaseButton: GestureHandler,
|
|
1209
1291
|
BorderlessButton: GestureHandler,
|
|
1210
|
-
createNativeWrapper: (comp:
|
|
1292
|
+
createNativeWrapper: <T>(comp: T): T => comp,
|
|
1211
1293
|
Directions: {
|
|
1212
1294
|
DOWN: 8,
|
|
1213
1295
|
LEFT: 2,
|
|
@@ -1218,21 +1300,21 @@ mock.module("react-native-gesture-handler", () => {
|
|
|
1218
1300
|
FlatList: GestureHandler,
|
|
1219
1301
|
FlingGestureHandler: GestureHandler,
|
|
1220
1302
|
Gesture: {
|
|
1221
|
-
Exclusive: (..._gestures:
|
|
1303
|
+
Exclusive: (..._gestures: unknown[]) => createChainableGesture(),
|
|
1222
1304
|
Fling: () => createChainableGesture(),
|
|
1223
1305
|
LongPress: () => createChainableGesture(),
|
|
1224
1306
|
Manual: () => createChainableGesture(),
|
|
1225
1307
|
Native: () => createChainableGesture(),
|
|
1226
1308
|
Pan: () => createChainableGesture(),
|
|
1227
1309
|
Pinch: () => createChainableGesture(),
|
|
1228
|
-
Race: (..._gestures:
|
|
1310
|
+
Race: (..._gestures: unknown[]) => createChainableGesture(),
|
|
1229
1311
|
Rotation: () => createChainableGesture(),
|
|
1230
|
-
Simultaneous: (..._gestures:
|
|
1312
|
+
Simultaneous: (..._gestures: unknown[]) => createChainableGesture(),
|
|
1231
1313
|
Tap: () => createChainableGesture(),
|
|
1232
1314
|
},
|
|
1233
1315
|
GestureDetector: GestureHandler,
|
|
1234
1316
|
GestureHandlerRootView: GestureHandler,
|
|
1235
|
-
gestureHandlerRootHOC: (comp:
|
|
1317
|
+
gestureHandlerRootHOC: <T>(comp: T): T => comp,
|
|
1236
1318
|
LongPressGestureHandler: GestureHandler,
|
|
1237
1319
|
NativeViewGestureHandler: GestureHandler,
|
|
1238
1320
|
PanGestureHandler: GestureHandler,
|
|
@@ -1260,11 +1342,11 @@ mock.module("react-native-gesture-handler", () => {
|
|
|
1260
1342
|
// Mock react-native-reanimated
|
|
1261
1343
|
mock.module("react-native-reanimated", () => {
|
|
1262
1344
|
const Animated = {
|
|
1263
|
-
createAnimatedComponent: (comp:
|
|
1264
|
-
Image: (props:
|
|
1265
|
-
ScrollView: ({children}:
|
|
1266
|
-
Text: ({children, style}:
|
|
1267
|
-
View: ({children, style}:
|
|
1345
|
+
createAnimatedComponent: <T>(comp: T): T => comp,
|
|
1346
|
+
Image: (props: MockComponentProps) => React.createElement("Image", props),
|
|
1347
|
+
ScrollView: ({children}: MockComponentProps) => React.createElement("ScrollView", {}, children),
|
|
1348
|
+
Text: ({children, style}: MockComponentProps) => React.createElement("Text", {style}, children),
|
|
1349
|
+
View: ({children, style}: MockComponentProps) => React.createElement("View", {style}, children),
|
|
1268
1350
|
};
|
|
1269
1351
|
return {
|
|
1270
1352
|
default: Animated,
|
|
@@ -1274,18 +1356,19 @@ mock.module("react-native-reanimated", () => {
|
|
|
1274
1356
|
linear: (t: number) => t,
|
|
1275
1357
|
quad: (t: number) => t,
|
|
1276
1358
|
},
|
|
1277
|
-
runOnJS: mock((fn:
|
|
1278
|
-
runOnUI: mock((fn:
|
|
1359
|
+
runOnJS: mock((fn: unknown) => fn),
|
|
1360
|
+
runOnUI: mock((fn: unknown) => fn),
|
|
1279
1361
|
useAnimatedGestureHandler: mock(() => ({})),
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1362
|
+
useAnimatedReaction: mock(() => undefined),
|
|
1363
|
+
useAnimatedStyle: mock((fn: () => unknown) => fn()),
|
|
1364
|
+
useDerivedValue: mock((fn: () => unknown) => ({value: fn()})),
|
|
1365
|
+
useSharedValue: mock((val: unknown) => ({value: val})),
|
|
1366
|
+
withDecay: mock((val: unknown) => val),
|
|
1367
|
+
withDelay: mock((_delay: unknown, val: unknown) => val),
|
|
1368
|
+
withRepeat: mock((val: unknown) => val),
|
|
1369
|
+
withSequence: mock((...vals: unknown[]) => vals[0]),
|
|
1370
|
+
withSpring: mock((val: unknown) => val),
|
|
1371
|
+
withTiming: mock((val: unknown) => val),
|
|
1289
1372
|
...Animated,
|
|
1290
1373
|
};
|
|
1291
1374
|
});
|
|
@@ -1294,7 +1377,7 @@ mock.module("react-native-reanimated", () => {
|
|
|
1294
1377
|
mock.module("react-native-svg", () => {
|
|
1295
1378
|
const createSvgComponent =
|
|
1296
1379
|
(name: string) =>
|
|
1297
|
-
({children, ...props}:
|
|
1380
|
+
({children, ...props}: MockComponentProps) =>
|
|
1298
1381
|
React.createElement(name, props, children);
|
|
1299
1382
|
|
|
1300
1383
|
return {
|