@terreno/ui 57.20.0 → 57.22.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.
- package/CHANGELOG.md +81 -0
- package/dist/Common.d.ts +60 -27
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +2 -2
- package/dist/DataTable.js.map +1 -1
- package/dist/DateTimeField.js +6 -6
- package/dist/DateTimeField.js.map +1 -1
- package/dist/HeightField.js +8 -8
- package/dist/HeightField.js.map +1 -1
- package/dist/OtpField.js +4 -4
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.js.map +1 -1
- package/dist/TapToEdit.d.ts +1 -1
- package/dist/TapToEdit.d.ts.map +1 -1
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TextField.js +4 -4
- package/dist/TextField.js.map +1 -1
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +16 -0
- package/dist/Theme.js.map +1 -1
- package/package.json +4 -2
- package/src/ActionSheet.test.tsx +13 -13
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +4 -4
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/Box.test.tsx +82 -74
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Common.ts +65 -29
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +3 -1
- package/src/ConsentNavigator.test.tsx +1 -2
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/DataTable.test.tsx +4 -4
- package/src/DataTable.tsx +2 -1
- package/src/DataTableVirtualizationRegression.test.tsx +1 -0
- package/src/DateTimeActionSheet.test.tsx +2 -0
- package/src/DateTimeField.test.tsx +3 -12
- package/src/DateTimeField.tsx +6 -6
- package/src/DismissButton.test.tsx +22 -4
- package/src/EmailField.test.tsx +13 -22
- package/src/EmojiSelector.test.tsx +2 -2
- package/src/ErrorBoundary.test.tsx +5 -3
- package/src/Field.test.tsx +20 -44
- package/src/GPTChat.test.tsx +24 -16
- package/src/Heading.test.tsx +1 -1
- package/src/HeightField.tsx +8 -8
- package/src/Icon.test.tsx +2 -2
- package/src/Image.test.tsx +1 -1
- package/src/Link.test.tsx +11 -4
- package/src/MarkdownView.test.tsx +1 -1
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +7 -2
- package/src/ModalSheet.test.tsx +5 -4
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.tsx +4 -4
- package/src/P0RenderRegression.test.tsx +7 -1
- package/src/P1RenderRegression.test.tsx +1 -0
- package/src/P2ButtonRenderRegression.test.tsx +1 -0
- package/src/Page.test.tsx +1 -1
- package/src/PhoneNumberField.test.tsx +14 -38
- package/src/PickerSelect.tsx +9 -9
- package/src/Popover.test.tsx +2 -2
- package/src/RadioField.test.tsx +7 -2
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/Signature.test.tsx +20 -23
- package/src/Slider.test.tsx +1 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/TapToEdit.test.tsx +38 -15
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/TextField.test.tsx +82 -9
- package/src/TextField.tsx +4 -4
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.webModal.test.tsx +2 -2
- package/src/Tooltip.test.tsx +3 -3
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +4 -2
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
- package/src/__snapshots__/Field.test.tsx.snap +4 -2
- package/src/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/__snapshots__/Image.test.tsx.snap +1 -1
- package/src/__snapshots__/Page.test.tsx.snap +2 -2
- package/src/__snapshots__/Text.test.tsx.snap +1 -1
- package/src/asks/AskCard.test.tsx +16 -13
- package/src/asks/AskFiles.test.tsx +5 -1
- package/src/asks/askFileRefs.test.ts +1 -1
- package/src/asks/askSummary.test.ts +2 -2
- package/src/benchmarks/importTiming.ts +1 -1
- package/src/blocks/BlocksView.test.tsx +20 -11
- package/src/bunSetup.ts +1 -1
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
- package/src/login/LoginScreen.test.tsx +6 -6
- package/src/security/PasswordCard.test.tsx +3 -3
- package/src/signUp/SignUpScreen.test.tsx +4 -4
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +56 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/useConsentForms.test.ts +1 -1
package/src/NumberField.test.tsx
CHANGED
|
@@ -8,13 +8,13 @@ const noOp = (): void => {};
|
|
|
8
8
|
|
|
9
9
|
describe("NumberField", () => {
|
|
10
10
|
it("renders correctly with default props", () => {
|
|
11
|
-
const {toJSON} = renderWithTheme(<NumberField
|
|
11
|
+
const {toJSON} = renderWithTheme(<NumberField onChange={noOp} type="number" />);
|
|
12
12
|
expect(toJSON()).toMatchSnapshot();
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
it("renders with initial value", () => {
|
|
16
16
|
const {getByDisplayValue} = renderWithTheme(
|
|
17
|
-
<NumberField
|
|
17
|
+
<NumberField onChange={noOp} type="number" value="42" />
|
|
18
18
|
);
|
|
19
19
|
expect(getByDisplayValue("42")).toBeTruthy();
|
|
20
20
|
});
|
|
@@ -22,7 +22,7 @@ describe("NumberField", () => {
|
|
|
22
22
|
it("calls onChange with valid integer", async () => {
|
|
23
23
|
const handleChange = mock((_value: string): void => {});
|
|
24
24
|
const {getByDisplayValue} = renderWithTheme(
|
|
25
|
-
<NumberField
|
|
25
|
+
<NumberField onChange={handleChange} type="number" value="" />
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const input = getByDisplayValue("");
|
|
@@ -38,7 +38,7 @@ describe("NumberField", () => {
|
|
|
38
38
|
it("does not call onChange with non-integer for number type", async () => {
|
|
39
39
|
const handleChange = mock((_value: string): void => {});
|
|
40
40
|
const {getByDisplayValue} = renderWithTheme(
|
|
41
|
-
<NumberField
|
|
41
|
+
<NumberField onChange={handleChange} type="number" value="" />
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
const input = getByDisplayValue("");
|
|
@@ -53,7 +53,7 @@ describe("NumberField", () => {
|
|
|
53
53
|
it("calls onChange with valid decimal", async () => {
|
|
54
54
|
const handleChange = mock((_value: string): void => {});
|
|
55
55
|
const {getByDisplayValue} = renderWithTheme(
|
|
56
|
-
<NumberField
|
|
56
|
+
<NumberField onChange={handleChange} type="decimal" value="" />
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
const input = getByDisplayValue("");
|
|
@@ -69,7 +69,7 @@ describe("NumberField", () => {
|
|
|
69
69
|
it("handles leading dot for decimal type", async () => {
|
|
70
70
|
const handleChange = mock((_value: string): void => {});
|
|
71
71
|
const {getByDisplayValue} = renderWithTheme(
|
|
72
|
-
<NumberField
|
|
72
|
+
<NumberField onChange={handleChange} type="decimal" value="" />
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
const input = getByDisplayValue("");
|
|
@@ -84,42 +84,42 @@ describe("NumberField", () => {
|
|
|
84
84
|
|
|
85
85
|
it("validates max value", () => {
|
|
86
86
|
const {getByText} = renderWithTheme(
|
|
87
|
-
<NumberField
|
|
87
|
+
<NumberField max={100} onChange={noOp} type="number" value="150" />
|
|
88
88
|
);
|
|
89
89
|
expect(getByText("Value must be less than or equal to 100")).toBeTruthy();
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it("validates min value", () => {
|
|
93
93
|
const {getByText} = renderWithTheme(
|
|
94
|
-
<NumberField
|
|
94
|
+
<NumberField min={10} onChange={noOp} type="number" value="5" />
|
|
95
95
|
);
|
|
96
96
|
expect(getByText("Value must be greater than or equal to 10")).toBeTruthy();
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
it("shows custom errorText", () => {
|
|
100
100
|
const {getByText} = renderWithTheme(
|
|
101
|
-
<NumberField errorText="Custom error"
|
|
101
|
+
<NumberField errorText="Custom error" onChange={noOp} type="number" value="" />
|
|
102
102
|
);
|
|
103
103
|
expect(getByText("Custom error")).toBeTruthy();
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
it("does not show error for valid number within range", () => {
|
|
107
107
|
const {queryByText} = renderWithTheme(
|
|
108
|
-
<NumberField
|
|
108
|
+
<NumberField max={100} min={0} onChange={noOp} type="number" value="50" />
|
|
109
109
|
);
|
|
110
110
|
expect(queryByText(/must be/)).toBeNull();
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
it("shows decimal error for non-numeric characters in decimal type", () => {
|
|
114
114
|
const {getByText} = renderWithTheme(
|
|
115
|
-
<NumberField
|
|
115
|
+
<NumberField onChange={noOp} type="decimal" value="12abc" />
|
|
116
116
|
);
|
|
117
117
|
expect(getByText("Value must be a decimal")).toBeTruthy();
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
it("shows decimal error for multiple decimal points", () => {
|
|
121
121
|
const {getByText} = renderWithTheme(
|
|
122
|
-
<NumberField
|
|
122
|
+
<NumberField onChange={noOp} type="decimal" value="1.2.3" />
|
|
123
123
|
);
|
|
124
124
|
expect(getByText("Value must be a decimal")).toBeTruthy();
|
|
125
125
|
});
|
|
@@ -127,14 +127,14 @@ describe("NumberField", () => {
|
|
|
127
127
|
it("syncs value when prop changes", async () => {
|
|
128
128
|
const handleChange = mock((_value: string): void => {});
|
|
129
129
|
const {getByDisplayValue, unmount} = renderWithTheme(
|
|
130
|
-
<NumberField
|
|
130
|
+
<NumberField onChange={handleChange} type="number" value="10" />
|
|
131
131
|
);
|
|
132
132
|
expect(getByDisplayValue("10")).toBeTruthy();
|
|
133
133
|
|
|
134
134
|
// Unmount and render with new value to test prop sync
|
|
135
135
|
unmount();
|
|
136
136
|
const {getByDisplayValue: getByDisplayValue2} = renderWithTheme(
|
|
137
|
-
<NumberField
|
|
137
|
+
<NumberField onChange={handleChange} type="number" value="20" />
|
|
138
138
|
);
|
|
139
139
|
expect(getByDisplayValue2("20")).toBeTruthy();
|
|
140
140
|
});
|
|
@@ -87,7 +87,7 @@ describe("NumberPickerActionSheet", () => {
|
|
|
87
87
|
);
|
|
88
88
|
// Replace the ref target with a mock after mount so the Button's onClick
|
|
89
89
|
// invokes our spy instead of the real ActionSheet instance.
|
|
90
|
-
(actionSheetRef as {current: {setModalVisible: typeof setModalVisible}}).current = {
|
|
90
|
+
(actionSheetRef as unknown as {current: {setModalVisible: typeof setModalVisible}}).current = {
|
|
91
91
|
setModalVisible,
|
|
92
92
|
};
|
|
93
93
|
const closeButtons = UNSAFE_getAllByProps({text: "Close"});
|
|
@@ -100,7 +100,7 @@ describe("OpenAPIContext", () => {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it("fetches spec and resolves model fields", async () => {
|
|
103
|
-
let capturedContext
|
|
103
|
+
let capturedContext = null as OpenAPIContextType | null;
|
|
104
104
|
render(
|
|
105
105
|
<OpenAPIProvider specUrl="https://api.example.com/openapi.json">
|
|
106
106
|
<ContextReader
|
|
@@ -125,7 +125,7 @@ describe("OpenAPIContext", () => {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
it("resolves nested model fields using dot notation", async () => {
|
|
128
|
-
let capturedContext
|
|
128
|
+
let capturedContext = null as OpenAPIContextType | null;
|
|
129
129
|
render(
|
|
130
130
|
<OpenAPIProvider specUrl="https://api.example.com/openapi.json">
|
|
131
131
|
<ContextReader
|
|
@@ -147,7 +147,7 @@ describe("OpenAPIContext", () => {
|
|
|
147
147
|
});
|
|
148
148
|
|
|
149
149
|
it("warns when model path is missing", async () => {
|
|
150
|
-
let capturedContext
|
|
150
|
+
let capturedContext = null as OpenAPIContextType | null;
|
|
151
151
|
render(
|
|
152
152
|
<OpenAPIProvider specUrl="https://api.example.com/openapi.json">
|
|
153
153
|
<ContextReader
|
|
@@ -167,7 +167,7 @@ describe("OpenAPIContext", () => {
|
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
it("warns when model field is missing", async () => {
|
|
170
|
-
let capturedContext
|
|
170
|
+
let capturedContext = null as OpenAPIContextType | null;
|
|
171
171
|
render(
|
|
172
172
|
<OpenAPIProvider specUrl="https://api.example.com/openapi.json">
|
|
173
173
|
<ContextReader
|
|
@@ -164,7 +164,7 @@ describe("OpenAPI context rerender regression coverage", () => {
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
it("keeps stable OpenAPI action references across equivalent provider renders", async () => {
|
|
167
|
-
let capturedContext
|
|
167
|
+
let capturedContext = null as ReturnType<typeof useOpenAPISpec> | null;
|
|
168
168
|
|
|
169
169
|
const result = render(
|
|
170
170
|
<OpenAPIProvider specUrl="https://api.example.com/openapi-v0.json">
|
package/src/OtpField.tsx
CHANGED
|
@@ -230,14 +230,14 @@ export const OtpField: FC<OtpFieldProps> = ({
|
|
|
230
230
|
|
|
231
231
|
const renderCell = (index: number): ReactElement => {
|
|
232
232
|
const isFocused = focusedIndex === index;
|
|
233
|
-
let borderColor = theme.border
|
|
233
|
+
let borderColor = theme.field.border;
|
|
234
234
|
let borderWidth = 1;
|
|
235
235
|
if (errorText || invalid) {
|
|
236
|
-
borderColor = theme.
|
|
236
|
+
borderColor = theme.field.borderError;
|
|
237
237
|
borderWidth = 2;
|
|
238
238
|
}
|
|
239
239
|
if (isFocused) {
|
|
240
|
-
borderColor = theme.
|
|
240
|
+
borderColor = theme.field.borderFocus;
|
|
241
241
|
borderWidth = 3;
|
|
242
242
|
}
|
|
243
243
|
return (
|
|
@@ -266,7 +266,7 @@ export const OtpField: FC<OtpFieldProps> = ({
|
|
|
266
266
|
selectTextOnFocus
|
|
267
267
|
style={
|
|
268
268
|
{
|
|
269
|
-
backgroundColor: disabled ? theme.
|
|
269
|
+
backgroundColor: disabled ? theme.field.backgroundDisabled : theme.field.background,
|
|
270
270
|
borderColor,
|
|
271
271
|
borderRadius: 4,
|
|
272
272
|
borderWidth,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {describe, it} from "bun:test";
|
|
1
2
|
import {act, render, waitFor} from "@testing-library/react-native";
|
|
2
3
|
import {assert} from "chai";
|
|
3
4
|
import type React from "react";
|
|
@@ -88,7 +89,12 @@ describe("P0 component rerender regression coverage", () => {
|
|
|
88
89
|
assert.exists(result.getByTestId("box"));
|
|
89
90
|
result.rerender(
|
|
90
91
|
<ThemeProvider>
|
|
91
|
-
<Box
|
|
92
|
+
<Box
|
|
93
|
+
accessibilityHint="Runs the box action"
|
|
94
|
+
accessibilityLabel="Box action"
|
|
95
|
+
onClick={onClick}
|
|
96
|
+
testID="box"
|
|
97
|
+
/>
|
|
92
98
|
</ThemeProvider>
|
|
93
99
|
);
|
|
94
100
|
|
package/src/Page.test.tsx
CHANGED
|
@@ -194,7 +194,7 @@ describe("Page", () => {
|
|
|
194
194
|
|
|
195
195
|
it("renders with custom color", () => {
|
|
196
196
|
const {toJSON} = renderWithTheme(
|
|
197
|
-
<Page color="
|
|
197
|
+
<Page color="secondaryDark" navigation={mockNavigation}>
|
|
198
198
|
<Text>Content</Text>
|
|
199
199
|
</Page>
|
|
200
200
|
);
|
|
@@ -6,65 +6,46 @@ import {renderWithTheme} from "./test-utils";
|
|
|
6
6
|
|
|
7
7
|
describe("PhoneNumberField", () => {
|
|
8
8
|
it("renders correctly with default props", () => {
|
|
9
|
-
const {toJSON} = renderWithTheme(
|
|
10
|
-
<PhoneNumberField label="Phone" onChange={() => {}} value="" />
|
|
11
|
-
);
|
|
9
|
+
const {toJSON} = renderWithTheme(<PhoneNumberField onChange={() => {}} value="" />);
|
|
12
10
|
expect(toJSON()).toMatchSnapshot();
|
|
13
11
|
});
|
|
14
12
|
|
|
15
13
|
it("renders with placeholder", () => {
|
|
16
14
|
const {getByPlaceholderText} = renderWithTheme(
|
|
17
|
-
<PhoneNumberField
|
|
18
|
-
label="Phone"
|
|
19
|
-
onChange={() => {}}
|
|
20
|
-
placeholder="Enter phone number"
|
|
21
|
-
value=""
|
|
22
|
-
/>
|
|
15
|
+
<PhoneNumberField onChange={() => {}} placeholder="Enter phone number" value="" />
|
|
23
16
|
);
|
|
24
17
|
expect(getByPlaceholderText("Enter phone number")).toBeTruthy();
|
|
25
18
|
});
|
|
26
19
|
|
|
27
20
|
it("renders with initial value", () => {
|
|
28
21
|
const {getByDisplayValue} = renderWithTheme(
|
|
29
|
-
<PhoneNumberField
|
|
22
|
+
<PhoneNumberField onChange={() => {}} value="(555) 123-4567" />
|
|
30
23
|
);
|
|
31
24
|
expect(getByDisplayValue("(555) 123-4567")).toBeTruthy();
|
|
32
25
|
});
|
|
33
26
|
|
|
34
27
|
it("renders with custom errorText", () => {
|
|
35
28
|
const {getByText} = renderWithTheme(
|
|
36
|
-
<PhoneNumberField
|
|
37
|
-
errorText="Phone number is required"
|
|
38
|
-
label="Phone"
|
|
39
|
-
onChange={() => {}}
|
|
40
|
-
value=""
|
|
41
|
-
/>
|
|
29
|
+
<PhoneNumberField errorText="Phone number is required" onChange={() => {}} value="" />
|
|
42
30
|
);
|
|
43
31
|
expect(getByText("Phone number is required")).toBeTruthy();
|
|
44
32
|
});
|
|
45
33
|
|
|
46
34
|
it("renders with icon", () => {
|
|
47
35
|
const {toJSON} = renderWithTheme(
|
|
48
|
-
<PhoneNumberField iconName="phone"
|
|
36
|
+
<PhoneNumberField iconName="phone" onChange={() => {}} value="" />
|
|
49
37
|
);
|
|
50
38
|
expect(toJSON()).toMatchSnapshot();
|
|
51
39
|
});
|
|
52
40
|
|
|
53
41
|
it("uses US as default country code", () => {
|
|
54
|
-
const {toJSON} = renderWithTheme(
|
|
55
|
-
<PhoneNumberField label="Phone" onChange={() => {}} value="5551234567" />
|
|
56
|
-
);
|
|
42
|
+
const {toJSON} = renderWithTheme(<PhoneNumberField onChange={() => {}} value="5551234567" />);
|
|
57
43
|
expect(toJSON()).toMatchSnapshot();
|
|
58
44
|
});
|
|
59
45
|
|
|
60
46
|
it("accepts custom country code", () => {
|
|
61
47
|
const {toJSON} = renderWithTheme(
|
|
62
|
-
<PhoneNumberField
|
|
63
|
-
defaultCountryCode="GB"
|
|
64
|
-
label="Phone"
|
|
65
|
-
onChange={() => {}}
|
|
66
|
-
value="7911123456"
|
|
67
|
-
/>
|
|
48
|
+
<PhoneNumberField defaultCountryCode="GB" onChange={() => {}} value="7911123456" />
|
|
68
49
|
);
|
|
69
50
|
expect(toJSON()).toMatchSnapshot();
|
|
70
51
|
});
|
|
@@ -73,12 +54,7 @@ describe("PhoneNumberField", () => {
|
|
|
73
54
|
const handleBlur = mock((_value: string) => {});
|
|
74
55
|
const handleChange = mock((_value: string) => {});
|
|
75
56
|
const {getByDisplayValue} = renderWithTheme(
|
|
76
|
-
<PhoneNumberField
|
|
77
|
-
label="Phone"
|
|
78
|
-
onBlur={handleBlur}
|
|
79
|
-
onChange={handleChange}
|
|
80
|
-
value="(555) 123-4567"
|
|
81
|
-
/>
|
|
57
|
+
<PhoneNumberField onBlur={handleBlur} onChange={handleChange} value="(555) 123-4567" />
|
|
82
58
|
);
|
|
83
59
|
const input = getByDisplayValue("(555) 123-4567");
|
|
84
60
|
await act(async () => {
|
|
@@ -91,7 +67,7 @@ describe("PhoneNumberField", () => {
|
|
|
91
67
|
const handleBlur = mock((_value: string) => {});
|
|
92
68
|
const handleChange = mock((_value: string) => {});
|
|
93
69
|
const {getByDisplayValue} = renderWithTheme(
|
|
94
|
-
<PhoneNumberField
|
|
70
|
+
<PhoneNumberField onBlur={handleBlur} onChange={handleChange} value="" />
|
|
95
71
|
);
|
|
96
72
|
const input = getByDisplayValue("");
|
|
97
73
|
await act(async () => {
|
|
@@ -105,7 +81,7 @@ describe("PhoneNumberField", () => {
|
|
|
105
81
|
const handleBlur = mock((_value: string) => {});
|
|
106
82
|
const handleChange = mock((_value: string) => {});
|
|
107
83
|
const {getByDisplayValue} = renderWithTheme(
|
|
108
|
-
<PhoneNumberField
|
|
84
|
+
<PhoneNumberField onBlur={handleBlur} onChange={handleChange} value="" />
|
|
109
85
|
);
|
|
110
86
|
const input = getByDisplayValue("");
|
|
111
87
|
await act(async () => {
|
|
@@ -117,7 +93,7 @@ describe("PhoneNumberField", () => {
|
|
|
117
93
|
it("shows 'Invalid phone number format' on blur when number cannot be parsed", async () => {
|
|
118
94
|
const handleChange = mock((_value: string) => {});
|
|
119
95
|
const {getByDisplayValue, getByText} = renderWithTheme(
|
|
120
|
-
<PhoneNumberField
|
|
96
|
+
<PhoneNumberField onChange={handleChange} value="abc" />
|
|
121
97
|
);
|
|
122
98
|
const input = getByDisplayValue("abc");
|
|
123
99
|
await act(async () => {
|
|
@@ -130,7 +106,7 @@ describe("PhoneNumberField", () => {
|
|
|
130
106
|
const handleChange = mock((_value: string) => {});
|
|
131
107
|
// A number that parses and isPossible() but not isValid() for US
|
|
132
108
|
const {getByDisplayValue, getByText} = renderWithTheme(
|
|
133
|
-
<PhoneNumberField
|
|
109
|
+
<PhoneNumberField onChange={handleChange} value="(555) 555-5555" />
|
|
134
110
|
);
|
|
135
111
|
const input = getByDisplayValue("(555) 555-5555");
|
|
136
112
|
await act(async () => {
|
|
@@ -142,7 +118,7 @@ describe("PhoneNumberField", () => {
|
|
|
142
118
|
it("uses inputValue as-is when it matches formattedValue or has length 4", async () => {
|
|
143
119
|
const handleChange = mock((_value: string) => {});
|
|
144
120
|
const {getByDisplayValue} = renderWithTheme(
|
|
145
|
-
<PhoneNumberField
|
|
121
|
+
<PhoneNumberField onChange={handleChange} value="" />
|
|
146
122
|
);
|
|
147
123
|
const input = getByDisplayValue("");
|
|
148
124
|
// Input of length 4 triggers the else branch (setLocalValue(inputValue))
|
|
@@ -157,7 +133,7 @@ describe("PhoneNumberField", () => {
|
|
|
157
133
|
// Start with an invalid value so that blur triggers the error path.
|
|
158
134
|
// TextField's onBlur uses its own value prop (localValue), not nativeEvent.text.
|
|
159
135
|
const {getByDisplayValue, getByText, queryByText} = renderWithTheme(
|
|
160
|
-
<PhoneNumberField
|
|
136
|
+
<PhoneNumberField onChange={handleChange} value="abc" />
|
|
161
137
|
);
|
|
162
138
|
const input = getByDisplayValue("abc");
|
|
163
139
|
// Blur triggers validatePhoneNumber("abc") → "Invalid phone number format"
|
package/src/PickerSelect.tsx
CHANGED
|
@@ -469,11 +469,11 @@ export const RNPickerSelect = ({
|
|
|
469
469
|
style={[
|
|
470
470
|
defaultStyles.viewContainer,
|
|
471
471
|
{
|
|
472
|
-
backgroundColor: theme.
|
|
473
|
-
borderColor: theme.border
|
|
472
|
+
backgroundColor: theme.field.background,
|
|
473
|
+
borderColor: theme.field.border,
|
|
474
474
|
},
|
|
475
475
|
disabled && {
|
|
476
|
-
backgroundColor: theme.
|
|
476
|
+
backgroundColor: theme.field.backgroundDisabled,
|
|
477
477
|
},
|
|
478
478
|
]}
|
|
479
479
|
>
|
|
@@ -589,12 +589,12 @@ export const RNPickerSelect = ({
|
|
|
589
589
|
style={[
|
|
590
590
|
defaultStyles.viewContainer,
|
|
591
591
|
{
|
|
592
|
-
backgroundColor: theme.
|
|
593
|
-
borderColor: theme.border
|
|
592
|
+
backgroundColor: theme.field.background,
|
|
593
|
+
borderColor: theme.field.border,
|
|
594
594
|
height: 40,
|
|
595
595
|
},
|
|
596
596
|
disabled && {
|
|
597
|
-
backgroundColor: theme.
|
|
597
|
+
backgroundColor: theme.field.backgroundDisabled,
|
|
598
598
|
},
|
|
599
599
|
]}
|
|
600
600
|
>
|
|
@@ -742,11 +742,11 @@ export const RNPickerSelect = ({
|
|
|
742
742
|
style={[
|
|
743
743
|
defaultStyles.viewContainer,
|
|
744
744
|
{
|
|
745
|
-
backgroundColor: theme.
|
|
746
|
-
borderColor: theme.border
|
|
745
|
+
backgroundColor: theme.field.background,
|
|
746
|
+
borderColor: theme.field.border,
|
|
747
747
|
},
|
|
748
748
|
disabled && {
|
|
749
|
-
backgroundColor: theme.
|
|
749
|
+
backgroundColor: theme.field.backgroundDisabled,
|
|
750
750
|
},
|
|
751
751
|
]}
|
|
752
752
|
>
|
package/src/Popover.test.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {fireEvent, waitFor} from "@testing-library/react-native";
|
|
|
3
3
|
|
|
4
4
|
import {Popover} from "./Popover";
|
|
5
5
|
import {Text} from "./Text";
|
|
6
|
-
import {renderWithTheme} from "./test-utils";
|
|
6
|
+
import {findByHostType, renderWithTheme} from "./test-utils";
|
|
7
7
|
|
|
8
8
|
describe("Popover", () => {
|
|
9
9
|
it("renders the title, date and body when loaded", () => {
|
|
@@ -110,7 +110,7 @@ describe("Popover", () => {
|
|
|
110
110
|
expect(scrollView.props.style).toEqual(
|
|
111
111
|
expect.objectContaining({flexBasis: 0, flexGrow: 1, flexShrink: 1, minHeight: 0})
|
|
112
112
|
);
|
|
113
|
-
const content = scrollView
|
|
113
|
+
const content = findByHostType(scrollView, "View");
|
|
114
114
|
expect(content.props.style?.height).toBeUndefined();
|
|
115
115
|
});
|
|
116
116
|
|
package/src/RadioField.test.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {describe, expect, it, mock} from "bun:test";
|
|
2
2
|
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
-
|
|
3
|
+
import type {FieldOption} from "./Common";
|
|
4
4
|
import {RadioField} from "./RadioField";
|
|
5
5
|
import {renderWithTheme} from "./test-utils";
|
|
6
6
|
|
|
@@ -78,7 +78,12 @@ describe("RadioField", () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
it("renders options using value when label is not provided", () => {
|
|
81
|
-
|
|
81
|
+
// FieldOption requires a label; untyped callers can still omit it.
|
|
82
|
+
const optionsWithoutLabels = [
|
|
83
|
+
{value: "first"},
|
|
84
|
+
{value: "second"},
|
|
85
|
+
{value: "third"},
|
|
86
|
+
] as unknown as FieldOption[];
|
|
82
87
|
const {getByText} = renderWithTheme(
|
|
83
88
|
<RadioField onChange={() => {}} options={optionsWithoutLabels} title="Title" value="" />
|
|
84
89
|
);
|
|
@@ -8,13 +8,15 @@ describe("SegmentedControl", () => {
|
|
|
8
8
|
const defaultItems = ["Tab 1", "Tab 2", "Tab 3"];
|
|
9
9
|
|
|
10
10
|
it("renders correctly with default props", () => {
|
|
11
|
-
const {toJSON} = renderWithTheme(
|
|
11
|
+
const {toJSON} = renderWithTheme(
|
|
12
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} />
|
|
13
|
+
);
|
|
12
14
|
expect(toJSON()).toMatchSnapshot();
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
it("renders all items", () => {
|
|
16
18
|
const {getByText} = renderWithTheme(
|
|
17
|
-
<SegmentedControl items={defaultItems} selectedIndex={0} />
|
|
19
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} />
|
|
18
20
|
);
|
|
19
21
|
expect(getByText("Tab 1")).toBeTruthy();
|
|
20
22
|
expect(getByText("Tab 2")).toBeTruthy();
|
|
@@ -22,7 +24,9 @@ describe("SegmentedControl", () => {
|
|
|
22
24
|
});
|
|
23
25
|
|
|
24
26
|
it("highlights selected item", () => {
|
|
25
|
-
const {toJSON} = renderWithTheme(
|
|
27
|
+
const {toJSON} = renderWithTheme(
|
|
28
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={1} />
|
|
29
|
+
);
|
|
26
30
|
expect(toJSON()).toMatchSnapshot();
|
|
27
31
|
});
|
|
28
32
|
|
|
@@ -38,21 +42,21 @@ describe("SegmentedControl", () => {
|
|
|
38
42
|
|
|
39
43
|
it("renders with medium size (default)", () => {
|
|
40
44
|
const {toJSON} = renderWithTheme(
|
|
41
|
-
<SegmentedControl items={defaultItems} selectedIndex={0} size="md" />
|
|
45
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} size="md" />
|
|
42
46
|
);
|
|
43
47
|
expect(toJSON()).toMatchSnapshot();
|
|
44
48
|
});
|
|
45
49
|
|
|
46
50
|
it("renders a compact control that hugs its labels", () => {
|
|
47
51
|
const {toJSON} = renderWithTheme(
|
|
48
|
-
<SegmentedControl items={defaultItems} selectedIndex={0} size="sm" />
|
|
52
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} size="sm" />
|
|
49
53
|
);
|
|
50
54
|
expect(toJSON()).toMatchSnapshot();
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
it("renders with large size", () => {
|
|
54
58
|
const {toJSON} = renderWithTheme(
|
|
55
|
-
<SegmentedControl items={defaultItems} selectedIndex={0} size="lg" />
|
|
59
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} size="lg" />
|
|
56
60
|
);
|
|
57
61
|
expect(toJSON()).toMatchSnapshot();
|
|
58
62
|
});
|
|
@@ -64,7 +68,12 @@ describe("SegmentedControl", () => {
|
|
|
64
68
|
{count: 1, status: "error" as const},
|
|
65
69
|
];
|
|
66
70
|
const {toJSON} = renderWithTheme(
|
|
67
|
-
<SegmentedControl
|
|
71
|
+
<SegmentedControl
|
|
72
|
+
badges={badges}
|
|
73
|
+
items={defaultItems}
|
|
74
|
+
onChange={() => {}}
|
|
75
|
+
selectedIndex={0}
|
|
76
|
+
/>
|
|
68
77
|
);
|
|
69
78
|
expect(toJSON()).toMatchSnapshot();
|
|
70
79
|
});
|
|
@@ -72,7 +81,7 @@ describe("SegmentedControl", () => {
|
|
|
72
81
|
it("renders with maxItems and scroll buttons", () => {
|
|
73
82
|
const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
|
|
74
83
|
const {toJSON} = renderWithTheme(
|
|
75
|
-
<SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
|
|
84
|
+
<SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
|
|
76
85
|
);
|
|
77
86
|
expect(toJSON()).toMatchSnapshot();
|
|
78
87
|
});
|
|
@@ -80,7 +89,7 @@ describe("SegmentedControl", () => {
|
|
|
80
89
|
it("handles scroll navigation", () => {
|
|
81
90
|
const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
|
|
82
91
|
const {getByText, toJSON} = renderWithTheme(
|
|
83
|
-
<SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
|
|
92
|
+
<SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
|
|
84
93
|
);
|
|
85
94
|
// Initially shows first 3 items
|
|
86
95
|
expect(getByText("Tab 1")).toBeTruthy();
|
|
@@ -92,7 +101,7 @@ describe("SegmentedControl", () => {
|
|
|
92
101
|
it("invokes handleNext when next scroll button is pressed", () => {
|
|
93
102
|
const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
|
|
94
103
|
const {UNSAFE_getAllByProps, queryByText} = renderWithTheme(
|
|
95
|
-
<SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
|
|
104
|
+
<SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
|
|
96
105
|
);
|
|
97
106
|
// Find the right chevron (next button) by its icon prop
|
|
98
107
|
const nextIcons = UNSAFE_getAllByProps({iconName: "chevron-right"});
|
|
@@ -109,7 +118,7 @@ describe("SegmentedControl", () => {
|
|
|
109
118
|
|
|
110
119
|
it("uses the default no-op onChange when none is provided", () => {
|
|
111
120
|
const {getByText} = renderWithTheme(
|
|
112
|
-
<SegmentedControl items={defaultItems} selectedIndex={0} />
|
|
121
|
+
<SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} />
|
|
113
122
|
);
|
|
114
123
|
|
|
115
124
|
expect(() => fireEvent.press(getByText("Tab 2"))).not.toThrow();
|
|
@@ -118,7 +127,7 @@ describe("SegmentedControl", () => {
|
|
|
118
127
|
it("invokes handlePrevious when previous scroll button is pressed", () => {
|
|
119
128
|
const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
|
|
120
129
|
const {UNSAFE_getAllByProps, queryByText} = renderWithTheme(
|
|
121
|
-
<SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
|
|
130
|
+
<SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
|
|
122
131
|
);
|
|
123
132
|
const nextIcons = UNSAFE_getAllByProps({iconName: "chevron-right"});
|
|
124
133
|
const nextPressable = nextIcons[0].parent;
|
|
@@ -103,7 +103,9 @@ describe("SidebarNavigationPanel", () => {
|
|
|
103
103
|
bottomItems={bottomItems}
|
|
104
104
|
onNavigate={onNavigate}
|
|
105
105
|
topItems={topItems}
|
|
106
|
-
|
|
106
|
+
>
|
|
107
|
+
{null}
|
|
108
|
+
</SidebarNavigationPanel>
|
|
107
109
|
);
|
|
108
110
|
|
|
109
111
|
for (const item of [...topItems, ...bottomItems]) {
|
|
@@ -134,7 +136,9 @@ describe("SidebarNavigationPanel", () => {
|
|
|
134
136
|
bottomItems={bottomItems}
|
|
135
137
|
onNavigate={onNavigate}
|
|
136
138
|
topItems={topItems}
|
|
137
|
-
|
|
139
|
+
>
|
|
140
|
+
{null}
|
|
141
|
+
</SidebarNavigationPanel>
|
|
138
142
|
);
|
|
139
143
|
|
|
140
144
|
fireEvent.press(getByLabelText("Settings"));
|
|
@@ -148,7 +152,9 @@ describe("SidebarNavigationPanel", () => {
|
|
|
148
152
|
bottomItems={bottomItems}
|
|
149
153
|
onNavigate={mock((_route: string) => {})}
|
|
150
154
|
topItems={topItems}
|
|
151
|
-
|
|
155
|
+
>
|
|
156
|
+
{null}
|
|
157
|
+
</SidebarNavigationPanel>
|
|
152
158
|
);
|
|
153
159
|
|
|
154
160
|
expect(queryByText("Home")).toBeNull();
|
|
@@ -175,7 +181,9 @@ describe("SidebarNavigationPanel", () => {
|
|
|
175
181
|
bottomItems={bottomItems}
|
|
176
182
|
onNavigate={mock((_route: string) => {})}
|
|
177
183
|
topItems={topItems}
|
|
178
|
-
|
|
184
|
+
>
|
|
185
|
+
{null}
|
|
186
|
+
</SidebarNavigationPanel>
|
|
179
187
|
);
|
|
180
188
|
|
|
181
189
|
const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
|
|
@@ -203,7 +211,9 @@ describe("SidebarNavigationPanel", () => {
|
|
|
203
211
|
bottomItems={bottomItems}
|
|
204
212
|
onNavigate={mock((_route: string) => {})}
|
|
205
213
|
topItems={topItems}
|
|
206
|
-
|
|
214
|
+
>
|
|
215
|
+
{null}
|
|
216
|
+
</SidebarNavigationPanel>
|
|
207
217
|
);
|
|
208
218
|
|
|
209
219
|
const item = getByLabelText("Alerts");
|
|
@@ -229,7 +239,9 @@ describe("SidebarNavigationPanel", () => {
|
|
|
229
239
|
onNavigate={mock((_route: string) => {})}
|
|
230
240
|
panelStyle={{borderRightWidth: 4}}
|
|
231
241
|
topItems={topItems}
|
|
232
|
-
|
|
242
|
+
>
|
|
243
|
+
{null}
|
|
244
|
+
</SidebarNavigationPanel>
|
|
233
245
|
);
|
|
234
246
|
|
|
235
247
|
const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
|