@terreno/ui 57.20.0 → 58.0.0-beta.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/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +93 -0
- package/dist/ActionSheet.d.ts +9 -9
- package/dist/ActionSheet.d.ts.map +1 -1
- package/dist/ActionSheet.js +11 -4
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AnnouncementNavigator.d.ts +7 -1
- package/dist/AnnouncementNavigator.d.ts.map +1 -1
- package/dist/AnnouncementNavigator.js +15 -16
- package/dist/AnnouncementNavigator.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +1 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +3 -1
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +71 -39
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/ConsentNavigator.d.ts +5 -3
- package/dist/ConsentNavigator.d.ts.map +1 -1
- package/dist/ConsentNavigator.js +4 -4
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/CustomSelectField.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +37 -12
- package/dist/DataTable.js.map +1 -1
- package/dist/DateTimeField.js +6 -6
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DropdownPanel.d.ts +0 -5
- package/dist/DropdownPanel.d.ts.map +1 -1
- package/dist/DropdownPanel.js +0 -5
- package/dist/DropdownPanel.js.map +1 -1
- package/dist/FilterAccordion.d.ts.map +1 -1
- package/dist/FilterAccordion.js.map +1 -1
- package/dist/FilterBoolean.d.ts.map +1 -1
- package/dist/FilterBoolean.js.map +1 -1
- package/dist/FilterSelectMenu.js +1 -1
- package/dist/FilterSelectMenu.js.map +1 -1
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +6 -12
- package/dist/Heading.js.map +1 -1
- package/dist/HeightField.d.ts.map +1 -1
- package/dist/HeightField.js +9 -9
- package/dist/HeightField.js.map +1 -1
- package/dist/Hyperlink.d.ts.map +1 -1
- package/dist/Hyperlink.js +6 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/MarkdownEditorField.d.ts.map +1 -1
- package/dist/MarkdownEditorField.js +1 -1
- package/dist/MarkdownEditorField.js.map +1 -1
- package/dist/OfflineBanner.d.ts +3 -2
- package/dist/OfflineBanner.d.ts.map +1 -1
- package/dist/OfflineBanner.js +3 -2
- package/dist/OfflineBanner.js.map +1 -1
- package/dist/OtpField.d.ts.map +1 -1
- package/dist/OtpField.js +4 -4
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.d.ts +4 -4
- package/dist/PickerSelect.d.ts.map +1 -1
- package/dist/PickerSelect.js +9 -9
- package/dist/PickerSelect.js.map +1 -1
- package/dist/ProvisionalConsentSigner.d.ts +3 -2
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -1
- package/dist/ProvisionalConsentSigner.js +2 -2
- package/dist/ProvisionalConsentSigner.js.map +1 -1
- package/dist/SidebarNavigation.js +2 -2
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +2 -2
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/Skeleton.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/Text.d.ts.map +1 -1
- package/dist/Text.js +27 -50
- package/dist/Text.js.map +1 -1
- package/dist/TextField.d.ts.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/dist/ThumbsUpDownFeedback.d.ts.map +1 -1
- package/dist/ThumbsUpDownFeedback.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.d.ts +1 -1
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +3 -3
- package/dist/WebDropdownMenu.d.ts.map +1 -1
- package/dist/WebDropdownMenu.js +1 -1
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/announcementPlatform.d.ts +5 -0
- package/dist/announcementPlatform.d.ts.map +1 -1
- package/dist/announcementPlatform.js +9 -0
- package/dist/announcementPlatform.js.map +1 -1
- package/dist/asks/AskCard.d.ts +2 -2
- package/dist/asks/AskCard.d.ts.map +1 -1
- package/dist/dataTableColumnWidths.d.ts +76 -0
- package/dist/dataTableColumnWidths.d.ts.map +1 -0
- package/dist/dataTableColumnWidths.js +181 -0
- package/dist/dataTableColumnWidths.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/requestClient.d.ts +71 -0
- package/dist/requestClient.d.ts.map +1 -0
- package/dist/requestClient.js +139 -0
- package/dist/requestClient.js.map +1 -0
- package/dist/security/PasswordCard.d.ts.map +1 -1
- package/dist/security/PasswordCard.js.map +1 -1
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -1
- package/dist/security/TwoFactorSettingsCard.js +1 -1
- package/dist/security/TwoFactorSettingsCard.js.map +1 -1
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/table/Table.d.ts.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableTitle.d.ts.map +1 -1
- package/dist/table/TableTitle.js +2 -1
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/textFontSizes.d.ts +12 -0
- package/dist/textFontSizes.d.ts.map +1 -0
- package/dist/textFontSizes.js +21 -0
- package/dist/textFontSizes.js.map +1 -0
- package/dist/useAcknowledgeAnnouncement.d.ts +8 -63
- package/dist/useAcknowledgeAnnouncement.d.ts.map +1 -1
- package/dist/useAcknowledgeAnnouncement.js +31 -80
- package/dist/useAcknowledgeAnnouncement.js.map +1 -1
- package/dist/useAnnouncements.d.ts +14 -47
- package/dist/useAnnouncements.d.ts.map +1 -1
- package/dist/useAnnouncements.js +30 -57
- package/dist/useAnnouncements.js.map +1 -1
- package/dist/useConsentForms.d.ts +6 -38
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +25 -48
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +7 -58
- package/dist/useProvisionalConsent.d.ts.map +1 -1
- package/dist/useProvisionalConsent.js +57 -67
- package/dist/useProvisionalConsent.js.map +1 -1
- package/dist/useSubmitConsent.d.ts +9 -39
- package/dist/useSubmitConsent.d.ts.map +1 -1
- package/dist/useSubmitConsent.js +10 -39
- package/dist/useSubmitConsent.js.map +1 -1
- package/package.json +40 -38
- package/src/ActionSheet.test.tsx +13 -13
- package/src/ActionSheet.tsx +18 -5
- package/src/AddressField.test.tsx +9 -3
- package/src/AnnouncementNavigator.test.tsx +219 -319
- package/src/AnnouncementNavigator.tsx +25 -20
- package/src/Avatar.tsx +2 -9
- package/src/Badge.test.tsx +1 -1
- package/src/Banner.test.tsx +0 -1
- package/src/Box.test.tsx +85 -77
- package/src/Box.tsx +4 -2
- package/src/Button.test.tsx +11 -6
- package/src/Card.test.tsx +2 -2
- package/src/Common.ts +79 -44
- package/src/ConflictSheet.test.tsx +5 -5
- package/src/ConsentFormScreen.test.tsx +3 -1
- package/src/ConsentFormScreen.tsx +2 -1
- package/src/ConsentNavigator.test.tsx +166 -243
- package/src/ConsentNavigator.tsx +9 -13
- package/src/CustomSelectField.test.tsx +16 -4
- package/src/CustomSelectField.tsx +3 -3
- package/src/DataTable.test.tsx +73 -5
- package/src/DataTable.tsx +72 -19
- 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 +10 -10
- package/src/DismissButton.test.tsx +22 -4
- package/src/DropdownPanel.tsx +0 -6
- 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/FilterAccordion.tsx +3 -3
- package/src/FilterBoolean.tsx +3 -3
- package/src/FilterSelectMenu.tsx +1 -1
- package/src/GPTChat.test.tsx +24 -16
- package/src/GPTChat.tsx +10 -9
- package/src/Heading.test.tsx +1 -1
- package/src/Heading.tsx +7 -14
- package/src/HeightField.tsx +17 -10
- package/src/Hyperlink.tsx +6 -3
- package/src/Icon.test.tsx +2 -2
- package/src/Image.test.tsx +1 -1
- package/src/Link.test.tsx +13 -6
- package/src/MarkdownEditorField.tsx +10 -2
- package/src/MarkdownView.test.tsx +10 -6
- package/src/MobileAddressAutoComplete.test.tsx +2 -1
- package/src/Modal.test.tsx +10 -3
- package/src/ModalSheet.test.tsx +11 -10
- package/src/MultiselectField.test.tsx +17 -3
- package/src/NumberField.test.tsx +14 -14
- package/src/NumberPickerActionSheet.test.tsx +1 -1
- package/src/OfflineBanner.tsx +3 -2
- package/src/OpenAPIContext.test.tsx +4 -4
- package/src/OpenAPIRenderRegression.test.tsx +1 -1
- package/src/OtpField.tsx +6 -5
- 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 +12 -11
- package/src/Popover.test.tsx +2 -2
- package/src/ProvisionalConsentSigner.test.tsx +140 -113
- package/src/ProvisionalConsentSigner.tsx +5 -4
- package/src/RadioField.test.tsx +7 -2
- package/src/SegmentedControl.test.tsx +21 -12
- package/src/SidebarNavigation.native.tsx +2 -2
- package/src/SidebarNavigation.test.tsx +18 -6
- package/src/SidebarNavigation.tsx +2 -2
- package/src/Signature.test.tsx +20 -23
- package/src/Skeleton.tsx +1 -1
- package/src/Slider.test.tsx +1 -1
- package/src/SplitPage.test.tsx +15 -5
- package/src/TapToEdit.test.tsx +40 -17
- package/src/TapToEdit.tsx +1 -1
- package/src/TerrenoFontProvider.test.tsx +1 -1
- package/src/Text.test.tsx +4 -4
- package/src/Text.tsx +25 -51
- package/src/TextField.test.tsx +82 -9
- package/src/TextField.tsx +6 -5
- package/src/Theme.test.tsx +49 -0
- package/src/Theme.tsx +16 -0
- package/src/ThumbsUpDownFeedback.tsx +3 -3
- package/src/Toast.test.tsx +5 -5
- package/src/ToastNotifications.test.tsx +73 -70
- package/src/ToastNotifications.tsx +3 -2
- package/src/ToastNotifications.webModal.test.tsx +6 -3
- package/src/Tooltip.test.tsx +3 -3
- package/src/Tooltip.tsx +2 -1
- package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
- package/src/UserInactivity.test.tsx +1 -0
- package/src/WebAddressAutocomplete.test.tsx +12 -12
- package/src/WebAddressAutocomplete.tsx +3 -3
- package/src/WebDropdownMenu.test.tsx +16 -15
- package/src/WebDropdownMenu.tsx +16 -5
- package/src/__snapshots__/Card.test.tsx.snap +1 -1
- package/src/__snapshots__/DataTable.test.tsx.snap +13 -0
- 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/announcementPlatform.ts +10 -0
- package/src/asks/AskCard.test.tsx +20 -15
- package/src/asks/AskCard.tsx +2 -2
- 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 +43 -1
- package/src/dataTableColumnWidths.test.ts +266 -0
- package/src/dataTableColumnWidths.ts +272 -0
- package/src/dataTableFilters.test.tsx +1 -1
- package/src/index.tsx +9 -2
- package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
- package/src/login/LoginScreen.test.tsx +6 -6
- package/src/login/LoginScreen.tsx +2 -2
- package/src/requestClient.test.ts +288 -0
- package/src/requestClient.ts +228 -0
- package/src/security/PasswordCard.test.tsx +3 -3
- package/src/security/PasswordCard.tsx +7 -5
- package/src/security/TwoFactorSettingsCard.tsx +10 -3
- package/src/signUp/SignUpScreen.test.tsx +4 -4
- package/src/signUp/SignUpScreen.tsx +2 -2
- package/src/table/Table.tsx +1 -2
- package/src/table/TableTitle.tsx +2 -1
- package/src/table/tableContext.test.tsx +5 -5
- package/src/test-utils.tsx +132 -1
- package/src/testing/reactDomServer.d.ts +7 -0
- package/src/textFontSizes.ts +31 -0
- package/src/useAcknowledgeAnnouncement.test.ts +101 -193
- package/src/useAcknowledgeAnnouncement.ts +69 -147
- package/src/useAnnouncements.test.ts +122 -186
- package/src/useAnnouncements.ts +49 -105
- package/src/useConsentForms.test.ts +59 -112
- package/src/useConsentForms.ts +37 -87
- package/src/useProvisionalConsent.test.ts +74 -150
- package/src/useProvisionalConsent.ts +79 -125
- package/src/useSubmitConsent.test.ts +59 -85
- package/src/useSubmitConsent.ts +22 -77
|
@@ -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;
|
|
@@ -469,7 +469,7 @@ const SidebarNavigationBase: FC<SidebarNavigationProps> = ({
|
|
|
469
469
|
topItems,
|
|
470
470
|
bottomItems,
|
|
471
471
|
onNavigate,
|
|
472
|
-
initialRouteName,
|
|
472
|
+
initialRouteName: _initialRouteName,
|
|
473
473
|
screenOptions,
|
|
474
474
|
panelStyle,
|
|
475
475
|
itemStyle,
|
|
@@ -478,7 +478,7 @@ const SidebarNavigationBase: FC<SidebarNavigationProps> = ({
|
|
|
478
478
|
const [isSheetOpen, setIsSheetOpen] = useState(false);
|
|
479
479
|
|
|
480
480
|
return (
|
|
481
|
-
<Navigator
|
|
481
|
+
<Navigator router={TabRouter} screenOptions={screenOptions}>
|
|
482
482
|
<View style={{flex: 1}}>
|
|
483
483
|
<SidebarHeader onOpen={() => setIsSheetOpen(true)} />
|
|
484
484
|
<SidebarNavigatorContent
|
|
@@ -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);
|
|
@@ -267,14 +267,14 @@ const SidebarNavigationBase: FC<SidebarNavigationProps> = ({
|
|
|
267
267
|
topItems,
|
|
268
268
|
bottomItems,
|
|
269
269
|
onNavigate,
|
|
270
|
-
initialRouteName,
|
|
270
|
+
initialRouteName: _initialRouteName,
|
|
271
271
|
screenOptions,
|
|
272
272
|
panelStyle,
|
|
273
273
|
itemStyle,
|
|
274
274
|
children,
|
|
275
275
|
}) => {
|
|
276
276
|
return (
|
|
277
|
-
<Navigator
|
|
277
|
+
<Navigator router={TabRouter} screenOptions={screenOptions}>
|
|
278
278
|
<SidebarNavigatorContent
|
|
279
279
|
bottomItems={bottomItems}
|
|
280
280
|
itemStyle={itemStyle}
|
package/src/Signature.test.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {afterEach, describe, expect, it, mock} from "bun:test";
|
|
2
2
|
import {act, fireEvent} from "@testing-library/react-native";
|
|
3
3
|
import {View} from "react-native";
|
|
4
|
+
import type {ReactTestInstance} from "react-test-renderer";
|
|
4
5
|
|
|
5
6
|
import {Signature} from "./Signature";
|
|
6
|
-
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
import {findAllByHostType, findByHostType, renderWithTheme} from "./test-utils";
|
|
7
8
|
|
|
8
9
|
const createMockContext = (): Record<string, ReturnType<typeof mock>> => ({
|
|
9
10
|
beginPath: mock(() => {}),
|
|
@@ -14,14 +15,10 @@ const createMockContext = (): Record<string, ReturnType<typeof mock>> => ({
|
|
|
14
15
|
});
|
|
15
16
|
|
|
16
17
|
const patchCanvasRefs = (
|
|
17
|
-
container:
|
|
18
|
-
findAll: (
|
|
19
|
-
predicate: (node: {type: string}) => boolean
|
|
20
|
-
) => Array<{props: Record<string, unknown>}>;
|
|
21
|
-
},
|
|
18
|
+
container: ReactTestInstance,
|
|
22
19
|
ctx: Record<string, ReturnType<typeof mock>>
|
|
23
20
|
): HTMLCanvasElement => {
|
|
24
|
-
const canvasNodes = container
|
|
21
|
+
const canvasNodes = findAllByHostType(container, "canvas");
|
|
25
22
|
const canvasNode = canvasNodes[0];
|
|
26
23
|
const canvas = {
|
|
27
24
|
getContext: mock(() => ctx),
|
|
@@ -65,8 +62,8 @@ describe("Signature", () => {
|
|
|
65
62
|
|
|
66
63
|
it("scales the web canvas to the available container width", () => {
|
|
67
64
|
const mockOnChange = mock(() => {});
|
|
68
|
-
const {
|
|
69
|
-
const canvas =
|
|
65
|
+
const {UNSAFE_root} = renderWithTheme(<Signature onChange={mockOnChange} />);
|
|
66
|
+
const canvas = findByHostType(UNSAFE_root, "canvas");
|
|
70
67
|
expect(canvas.props.style).toMatchObject({maxWidth: "100%", width: "100%"});
|
|
71
68
|
});
|
|
72
69
|
|
|
@@ -81,8 +78,8 @@ describe("Signature", () => {
|
|
|
81
78
|
const mockOnChange = mock(() => {});
|
|
82
79
|
const moveTo = mock(() => {});
|
|
83
80
|
const lineTo = mock(() => {});
|
|
84
|
-
const {
|
|
85
|
-
const canvas =
|
|
81
|
+
const {UNSAFE_root} = renderWithTheme(<Signature onChange={mockOnChange} />);
|
|
82
|
+
const canvas = findByHostType(UNSAFE_root, "canvas");
|
|
86
83
|
canvas.props.ref.current = {
|
|
87
84
|
clientHeight: 180,
|
|
88
85
|
clientWidth: 150,
|
|
@@ -131,7 +128,7 @@ describe("Signature", () => {
|
|
|
131
128
|
|
|
132
129
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
133
130
|
|
|
134
|
-
const canvasNodes = UNSAFE_root
|
|
131
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
135
132
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
136
133
|
|
|
137
134
|
act(() => {
|
|
@@ -153,7 +150,7 @@ describe("Signature", () => {
|
|
|
153
150
|
|
|
154
151
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
155
152
|
|
|
156
|
-
const canvasNodes = UNSAFE_root
|
|
153
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
157
154
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
158
155
|
|
|
159
156
|
act(() => {
|
|
@@ -181,7 +178,7 @@ describe("Signature", () => {
|
|
|
181
178
|
|
|
182
179
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
183
180
|
|
|
184
|
-
const canvasNodes = UNSAFE_root
|
|
181
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
185
182
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
186
183
|
|
|
187
184
|
act(() => {
|
|
@@ -202,7 +199,7 @@ describe("Signature", () => {
|
|
|
202
199
|
|
|
203
200
|
const canvas = patchCanvasRefs(UNSAFE_root, ctx);
|
|
204
201
|
|
|
205
|
-
const canvasNodes = UNSAFE_root
|
|
202
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
206
203
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
207
204
|
|
|
208
205
|
// Start drawing
|
|
@@ -243,7 +240,7 @@ describe("Signature", () => {
|
|
|
243
240
|
|
|
244
241
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
245
242
|
|
|
246
|
-
const canvasNodes = UNSAFE_root
|
|
243
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
247
244
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
248
245
|
|
|
249
246
|
// pointerDown without any move (no drawing)
|
|
@@ -273,7 +270,7 @@ describe("Signature", () => {
|
|
|
273
270
|
|
|
274
271
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
275
272
|
|
|
276
|
-
const canvasNodes = UNSAFE_root
|
|
273
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
277
274
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
278
275
|
|
|
279
276
|
act(() => {
|
|
@@ -295,7 +292,7 @@ describe("Signature", () => {
|
|
|
295
292
|
|
|
296
293
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
297
294
|
|
|
298
|
-
const canvasNodes = UNSAFE_root
|
|
295
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
299
296
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
300
297
|
|
|
301
298
|
// Draw something
|
|
@@ -331,7 +328,7 @@ describe("Signature", () => {
|
|
|
331
328
|
|
|
332
329
|
patchCanvasRefs(UNSAFE_root, ctx);
|
|
333
330
|
|
|
334
|
-
const canvasNodes = UNSAFE_root
|
|
331
|
+
const canvasNodes = findAllByHostType(UNSAFE_root, "canvas");
|
|
335
332
|
const canvasProps = canvasNodes[0].props as Record<string, (...args: unknown[]) => void>;
|
|
336
333
|
|
|
337
334
|
// Draw
|
|
@@ -366,10 +363,10 @@ describe("Signature", () => {
|
|
|
366
363
|
it("ignores pointer down when the canvas ref is missing", () => {
|
|
367
364
|
const mockOnChange = mock(() => {});
|
|
368
365
|
const mockOnStart = mock(() => {});
|
|
369
|
-
const {
|
|
366
|
+
const {UNSAFE_root} = renderWithTheme(
|
|
370
367
|
<Signature onChange={mockOnChange} onStart={mockOnStart} />
|
|
371
368
|
);
|
|
372
|
-
const canvas =
|
|
369
|
+
const canvas = findByHostType(UNSAFE_root, "canvas");
|
|
373
370
|
canvas.props.ref.current = null;
|
|
374
371
|
|
|
375
372
|
act(() => {
|
|
@@ -385,8 +382,8 @@ describe("Signature", () => {
|
|
|
385
382
|
it("falls back to raw offsets when the canvas has no measurable size", () => {
|
|
386
383
|
const mockOnChange = mock(() => {});
|
|
387
384
|
const moveTo = mock(() => {});
|
|
388
|
-
const {
|
|
389
|
-
const canvas =
|
|
385
|
+
const {UNSAFE_root} = renderWithTheme(<Signature onChange={mockOnChange} />);
|
|
386
|
+
const canvas = findByHostType(UNSAFE_root, "canvas");
|
|
390
387
|
canvas.props.ref.current = {
|
|
391
388
|
clientHeight: 0,
|
|
392
389
|
clientWidth: 0,
|
package/src/Skeleton.tsx
CHANGED
|
@@ -242,7 +242,7 @@ export const Skeleton: FC<SkeletonProps> = ({
|
|
|
242
242
|
}),
|
|
243
243
|
}
|
|
244
244
|
: {}),
|
|
245
|
-
} as Animated.
|
|
245
|
+
} as Animated.WithAnimatedValue<ViewStyle>;
|
|
246
246
|
|
|
247
247
|
return (
|
|
248
248
|
<Animated.View {...HIDDEN_FROM_ACCESSIBILITY} style={style} {...toTestProps(testID)}>
|
package/src/Slider.test.tsx
CHANGED
package/src/SplitPage.test.tsx
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import {afterAll, afterEach, beforeEach, describe, expect, it, mock, spyOn} from "bun:test";
|
|
2
2
|
import {act, fireEvent} from "@testing-library/react-native";
|
|
3
3
|
import {forwardRef, type ReactElement, type ReactNode, type Ref, useImperativeHandle} from "react";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type ScaledSize,
|
|
6
|
+
ScrollView,
|
|
7
|
+
type StyleProp,
|
|
8
|
+
StyleSheet,
|
|
9
|
+
useWindowDimensions,
|
|
10
|
+
View,
|
|
11
|
+
type ViewStyle,
|
|
12
|
+
} from "react-native";
|
|
5
13
|
import type {ReactTestInstance} from "react-test-renderer";
|
|
6
14
|
|
|
7
15
|
import {getRounding, getSpacing} from "./Common";
|
|
@@ -53,11 +61,13 @@ const setWindowWidth = (width: number): (() => void) => {
|
|
|
53
61
|
};
|
|
54
62
|
};
|
|
55
63
|
|
|
56
|
-
const styleWidth = (style:
|
|
64
|
+
const styleWidth = (style: StyleProp<ViewStyle>): ViewStyle["width"] =>
|
|
65
|
+
StyleSheet.flatten(style)?.width;
|
|
57
66
|
|
|
58
|
-
const styleBorderRadius = (style:
|
|
67
|
+
const styleBorderRadius = (style: StyleProp<ViewStyle>): ViewStyle["borderRadius"] =>
|
|
68
|
+
StyleSheet.flatten(style)?.borderRadius;
|
|
59
69
|
|
|
60
|
-
const flattenedStyle = (style:
|
|
70
|
+
const flattenedStyle = (style: StyleProp<ViewStyle>): ViewStyle => {
|
|
61
71
|
return StyleSheet.flatten(style) ?? {};
|
|
62
72
|
};
|
|
63
73
|
|
|
@@ -1102,7 +1112,7 @@ describe("SplitPage", () => {
|
|
|
1102
1112
|
const expectClippingPane = (
|
|
1103
1113
|
pane: ReactTestInstance,
|
|
1104
1114
|
borderRadius: number,
|
|
1105
|
-
width:
|
|
1115
|
+
width: ViewStyle["width"]
|
|
1106
1116
|
): void => {
|
|
1107
1117
|
const style = flattenedStyle(pane.props.style);
|
|
1108
1118
|
expect(style.borderRadius).toBe(borderRadius);
|
package/src/TapToEdit.test.tsx
CHANGED
|
@@ -8,14 +8,14 @@ import {renderWithTheme} from "./test-utils";
|
|
|
8
8
|
describe("TapToEdit", () => {
|
|
9
9
|
it("renders correctly with text value", () => {
|
|
10
10
|
const {toJSON} = renderWithTheme(
|
|
11
|
-
<TapToEdit setValue={() => {}} title="Name" value="John Doe" />
|
|
11
|
+
<TapToEdit setValue={() => {}} title="Name" type="text" value="John Doe" />
|
|
12
12
|
);
|
|
13
13
|
expect(toJSON()).toMatchSnapshot();
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it("displays title and value", () => {
|
|
17
17
|
const {getByText} = renderWithTheme(
|
|
18
|
-
<TapToEdit setValue={() => {}} title="Email" value="test@example.com" />
|
|
18
|
+
<TapToEdit setValue={() => {}} title="Email" type="text" value="test@example.com" />
|
|
19
19
|
);
|
|
20
20
|
expect(getByText("Email")).toBeTruthy();
|
|
21
21
|
expect(getByText("test@example.com")).toBeTruthy();
|
|
@@ -23,21 +23,27 @@ describe("TapToEdit", () => {
|
|
|
23
23
|
|
|
24
24
|
it("renders non-editable when editable is false", () => {
|
|
25
25
|
const {toJSON} = renderWithTheme(
|
|
26
|
-
<TapToEdit editable={false} title="Read Only" value="Cannot edit this" />
|
|
26
|
+
<TapToEdit editable={false} title="Read Only" type="text" value="Cannot edit this" />
|
|
27
27
|
);
|
|
28
28
|
expect(toJSON()).toMatchSnapshot();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it("renders edit icon when editable", () => {
|
|
32
32
|
const {toJSON} = renderWithTheme(
|
|
33
|
-
<TapToEdit
|
|
33
|
+
<TapToEdit
|
|
34
|
+
editable
|
|
35
|
+
setValue={() => {}}
|
|
36
|
+
title="Editable Field"
|
|
37
|
+
type="text"
|
|
38
|
+
value="Click to edit"
|
|
39
|
+
/>
|
|
34
40
|
);
|
|
35
41
|
expect(toJSON()).toMatchSnapshot();
|
|
36
42
|
});
|
|
37
43
|
|
|
38
44
|
it("shows editing mode when isEditing is true", () => {
|
|
39
45
|
const {toJSON} = renderWithTheme(
|
|
40
|
-
<TapToEdit isEditing setValue={() => {}} title="Field" value="Editing..." />
|
|
46
|
+
<TapToEdit isEditing setValue={() => {}} title="Field" type="text" value="Editing..." />
|
|
41
47
|
);
|
|
42
48
|
expect(toJSON()).toMatchSnapshot();
|
|
43
49
|
});
|
|
@@ -49,6 +55,7 @@ describe("TapToEdit", () => {
|
|
|
49
55
|
onlyShowHelperTextWhileEditing={false}
|
|
50
56
|
setValue={() => {}}
|
|
51
57
|
title="Name"
|
|
58
|
+
type="text"
|
|
52
59
|
value=""
|
|
53
60
|
/>
|
|
54
61
|
);
|
|
@@ -75,6 +82,7 @@ describe("TapToEdit", () => {
|
|
|
75
82
|
editable={false}
|
|
76
83
|
title="Custom"
|
|
77
84
|
transform={(val) => `Transformed: ${val}`}
|
|
85
|
+
type="text"
|
|
78
86
|
value="data"
|
|
79
87
|
/>
|
|
80
88
|
);
|
|
@@ -95,7 +103,13 @@ describe("TapToEdit", () => {
|
|
|
95
103
|
|
|
96
104
|
it("renders multiselect type as comma-joined string", () => {
|
|
97
105
|
const {getByText} = renderWithTheme(
|
|
98
|
-
<TapToEdit
|
|
106
|
+
<TapToEdit
|
|
107
|
+
editable={false}
|
|
108
|
+
options={[]}
|
|
109
|
+
title="Tags"
|
|
110
|
+
type="multiselect"
|
|
111
|
+
value={["a", "b", "c"]}
|
|
112
|
+
/>
|
|
99
113
|
);
|
|
100
114
|
expect(getByText("a, b, c")).toBeTruthy();
|
|
101
115
|
});
|
|
@@ -139,7 +153,7 @@ describe("TapToEdit", () => {
|
|
|
139
153
|
});
|
|
140
154
|
|
|
141
155
|
it("invokes Linking.openURL for url type when clicked", async () => {
|
|
142
|
-
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve(
|
|
156
|
+
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve());
|
|
143
157
|
|
|
144
158
|
const {getByLabelText} = renderWithTheme(
|
|
145
159
|
<TapToEdit editable={false} title="Site" type="url" value="https://example.com" />
|
|
@@ -154,7 +168,7 @@ describe("TapToEdit", () => {
|
|
|
154
168
|
});
|
|
155
169
|
|
|
156
170
|
it("invokes Linking.openURL with google maps for address type when clicked", async () => {
|
|
157
|
-
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve(
|
|
171
|
+
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve());
|
|
158
172
|
|
|
159
173
|
const {getByLabelText} = renderWithTheme(
|
|
160
174
|
<TapToEdit
|
|
@@ -177,14 +191,14 @@ describe("TapToEdit", () => {
|
|
|
177
191
|
|
|
178
192
|
it("throws when editable is true and setValue is not provided", () => {
|
|
179
193
|
expect(() =>
|
|
180
|
-
renderWithTheme(<TapToEdit editable title="Required Save" value="foo" />)
|
|
194
|
+
renderWithTheme(<TapToEdit editable title="Required Save" type="text" value="foo" />)
|
|
181
195
|
).toThrow();
|
|
182
196
|
});
|
|
183
197
|
|
|
184
198
|
it("enters editing mode when Edit button is pressed", async () => {
|
|
185
199
|
const setValue = mock(() => {});
|
|
186
200
|
const {getByLabelText, queryByText} = renderWithTheme(
|
|
187
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
201
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
188
202
|
);
|
|
189
203
|
await act(async () => {
|
|
190
204
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -196,7 +210,7 @@ describe("TapToEdit", () => {
|
|
|
196
210
|
it("calls setValue with initial value and exits editing on Cancel", async () => {
|
|
197
211
|
const setValue = mock(() => {});
|
|
198
212
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
199
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
213
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
200
214
|
);
|
|
201
215
|
await act(async () => {
|
|
202
216
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -210,7 +224,7 @@ describe("TapToEdit", () => {
|
|
|
210
224
|
it("reverts to original value (not edited value) when Cancel is pressed", async () => {
|
|
211
225
|
const setValue = mock((_v: unknown) => {});
|
|
212
226
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
213
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
227
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
214
228
|
);
|
|
215
229
|
await act(async () => {
|
|
216
230
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -227,7 +241,14 @@ describe("TapToEdit", () => {
|
|
|
227
241
|
const setValue = mock(() => {});
|
|
228
242
|
const onSave = mock(() => Promise.resolve());
|
|
229
243
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
230
|
-
<TapToEdit
|
|
244
|
+
<TapToEdit
|
|
245
|
+
onSave={onSave}
|
|
246
|
+
setValue={setValue}
|
|
247
|
+
showClearButton
|
|
248
|
+
title="Name"
|
|
249
|
+
type="text"
|
|
250
|
+
value="Jane"
|
|
251
|
+
/>
|
|
231
252
|
);
|
|
232
253
|
await act(async () => {
|
|
233
254
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -243,7 +264,7 @@ describe("TapToEdit", () => {
|
|
|
243
264
|
const setValue = mock(() => {});
|
|
244
265
|
const onSave = mock(() => Promise.resolve());
|
|
245
266
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
246
|
-
<TapToEdit onSave={onSave} setValue={setValue} title="Name" value="Jane" />
|
|
267
|
+
<TapToEdit onSave={onSave} setValue={setValue} title="Name" type="text" value="Jane" />
|
|
247
268
|
);
|
|
248
269
|
await act(async () => {
|
|
249
270
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -261,7 +282,7 @@ describe("TapToEdit", () => {
|
|
|
261
282
|
console.error = errorMock;
|
|
262
283
|
|
|
263
284
|
const {getByLabelText, getByText} = renderWithTheme(
|
|
264
|
-
<TapToEdit setValue={setValue} title="Name" value="Jane" />
|
|
285
|
+
<TapToEdit setValue={setValue} title="Name" type="text" value="Jane" />
|
|
265
286
|
);
|
|
266
287
|
await act(async () => {
|
|
267
288
|
fireEvent.press(getByLabelText("Edit"));
|
|
@@ -389,6 +410,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
389
410
|
editable={false}
|
|
390
411
|
helperText="Should be hidden in title"
|
|
391
412
|
title="Field"
|
|
413
|
+
type="text"
|
|
392
414
|
value="val"
|
|
393
415
|
/>
|
|
394
416
|
);
|
|
@@ -406,7 +428,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
406
428
|
|
|
407
429
|
it("forwards testID to the edit control", () => {
|
|
408
430
|
const {getByTestId} = renderWithTheme(
|
|
409
|
-
<TapToEdit setValue={() => {}} testID="profile.name" title="Name" value="Jane" />
|
|
431
|
+
<TapToEdit setValue={() => {}} testID="profile.name" title="Name" type="text" value="Jane" />
|
|
410
432
|
);
|
|
411
433
|
expect(getByTestId("profile.name.edit-clickable")).toBeTruthy();
|
|
412
434
|
});
|
|
@@ -419,6 +441,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
419
441
|
showClearButton
|
|
420
442
|
testID="profile.name"
|
|
421
443
|
title="Name"
|
|
444
|
+
type="text"
|
|
422
445
|
value="Jane"
|
|
423
446
|
/>
|
|
424
447
|
);
|
|
@@ -435,7 +458,7 @@ describe("TapToEdit - additional function coverage", () => {
|
|
|
435
458
|
|
|
436
459
|
it("does not set action testIDs when testID is omitted", async () => {
|
|
437
460
|
const {getByLabelText, queryByTestId} = renderWithTheme(
|
|
438
|
-
<TapToEdit setValue={() => {}} showClearButton title="Name" value="Jane" />
|
|
461
|
+
<TapToEdit setValue={() => {}} showClearButton title="Name" type="text" value="Jane" />
|
|
439
462
|
);
|
|
440
463
|
|
|
441
464
|
expect(queryByTestId("undefined.edit-clickable")).toBeNull();
|
package/src/TapToEdit.tsx
CHANGED
|
@@ -27,7 +27,7 @@ const TapToEditTitle: FC<{
|
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export const formatAddress = (address: AddressInterface
|
|
30
|
+
export const formatAddress = (address: Partial<AddressInterface>, asString = false): string => {
|
|
31
31
|
let city = "";
|
|
32
32
|
if (address?.city) {
|
|
33
33
|
city = address?.state || address.zipcode ? `${address.city}, ` : `${address.city}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import {describe, it, type mock} from "bun:test";
|
|
2
2
|
import {useFonts as useTextFonts} from "@expo-google-fonts/nunito";
|
|
3
3
|
import {useFonts as useHeadingFonts} from "@expo-google-fonts/titillium-web";
|
|
4
4
|
import {render} from "@testing-library/react-native";
|
package/src/Text.test.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {describe, expect, it, spyOn} from "bun:test";
|
|
2
2
|
import {render} from "@testing-library/react-native";
|
|
3
3
|
import {createRef} from "react";
|
|
4
|
-
import type {
|
|
4
|
+
import type {TextInstance as NativeText, TextProps} from "react-native";
|
|
5
5
|
|
|
6
6
|
import {Text} from "./Text";
|
|
7
7
|
import {ThemeProvider} from "./Theme";
|
|
8
|
-
import {renderWithTheme} from "./test-utils";
|
|
8
|
+
import {elementProps, renderWithTheme} from "./test-utils";
|
|
9
9
|
|
|
10
10
|
describe("Text", () => {
|
|
11
11
|
it("renders correctly with default props", () => {
|
|
@@ -116,7 +116,7 @@ describe("Text", () => {
|
|
|
116
116
|
|
|
117
117
|
// Color tests
|
|
118
118
|
it("renders with secondary color", () => {
|
|
119
|
-
const {toJSON} = renderWithTheme(<Text color="
|
|
119
|
+
const {toJSON} = renderWithTheme(<Text color="secondaryDark">Secondary color</Text>);
|
|
120
120
|
expect(toJSON()).toMatchSnapshot();
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -177,7 +177,7 @@ describe("Text", () => {
|
|
|
177
177
|
</Text>,
|
|
178
178
|
{
|
|
179
179
|
createNodeMock: (element) =>
|
|
180
|
-
element.
|
|
180
|
+
elementProps<TextProps>(element).accessibilityRole === "header" ? nativeText : null,
|
|
181
181
|
wrapper: ThemeProvider,
|
|
182
182
|
}
|
|
183
183
|
);
|