@terreno/ui 0.0.14 → 0.0.16
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/README.md +1 -1
- package/dist/Card.d.ts +1 -1
- package/dist/Card.js +2 -2
- package/dist/Card.js.map +1 -1
- package/dist/DateUtilities.js +2 -2
- package/package.json +1 -1
- package/src/ActionSheet.test.tsx +77 -0
- package/src/Banner.test.tsx +106 -0
- package/src/Body.test.tsx +79 -0
- package/src/BooleanField.test.tsx +84 -0
- package/src/Button.test.tsx +160 -0
- package/src/Card.test.tsx +61 -0
- package/src/Card.tsx +1 -2
- package/src/CheckBox.test.tsx +53 -0
- package/src/CustomSelectField.test.tsx +85 -0
- package/src/DataTable.test.tsx +133 -0
- package/src/DateTimeActionSheet.test.tsx +16 -0
- package/src/DateUtilities.tsx +2 -2
- package/src/DecimalRangeActionSheet.test.tsx +46 -0
- package/src/DismissButton.test.tsx +49 -0
- package/src/EmailField.test.tsx +106 -0
- package/src/ErrorBoundary.test.tsx +44 -0
- package/src/ErrorPage.test.tsx +44 -0
- package/src/Field.test.tsx +128 -0
- package/src/Heading.test.tsx +66 -0
- package/src/HeightActionSheet.test.tsx +34 -0
- package/src/Hyperlink.test.tsx +52 -0
- package/src/Icon.test.tsx +61 -0
- package/src/IconButton.test.tsx +145 -0
- package/src/Image.test.tsx +65 -0
- package/src/ImageBackground.test.tsx +46 -0
- package/src/InfoModalIcon.test.tsx +54 -0
- package/src/InfoTooltipButton.test.tsx +22 -0
- package/src/Link.test.tsx +64 -0
- package/src/MarkdownView.test.tsx +50 -0
- package/src/MobileAddressAutoComplete.test.tsx +15 -0
- package/src/Modal.test.tsx +169 -0
- package/src/ModalSheet.test.tsx +20 -0
- package/src/MultiselectField.test.tsx +134 -0
- package/src/NumberField.test.tsx +133 -0
- package/src/NumberPickerActionSheet.test.tsx +46 -0
- package/src/OpenAPIContext.test.tsx +36 -0
- package/src/Page.test.tsx +128 -0
- package/src/Pagination.test.tsx +86 -0
- package/src/PasswordField.test.tsx +17 -0
- package/src/PhoneNumberField.test.tsx +79 -0
- package/src/PickerSelect.test.tsx +16 -0
- package/src/Radio.test.tsx +30 -0
- package/src/RadioField.test.tsx +89 -0
- package/src/SectionDivider.test.tsx +17 -0
- package/src/SegmentedControl.test.tsx +84 -0
- package/src/SelectBadge.test.tsx +103 -0
- package/src/SelectField.test.tsx +84 -0
- package/src/SideDrawer.test.tsx +99 -0
- package/src/Signature.test.tsx +15 -0
- package/src/SignatureField.test.tsx +16 -0
- package/src/Spinner.test.tsx +74 -0
- package/src/SplitPage.test.tsx +15 -0
- package/src/TapToEdit.test.tsx +147 -0
- package/src/TerrenoProvider.test.tsx +36 -0
- package/src/Text.test.tsx +147 -0
- package/src/Theme.test.tsx +153 -0
- package/src/TimezonePicker.test.tsx +57 -0
- package/src/Toast.test.tsx +82 -0
- package/src/Tooltip.test.tsx +89 -0
- package/src/UnifiedAddressAutoComplete.test.tsx +15 -0
- package/src/Utilities.test.tsx +237 -0
- package/src/WebAddressAutocomplete.test.tsx +15 -0
- package/src/__snapshots__/ActionSheet.test.tsx.snap +889 -0
- package/src/__snapshots__/Banner.test.tsx.snap +546 -0
- package/src/__snapshots__/Body.test.tsx.snap +685 -0
- package/src/__snapshots__/BooleanField.test.tsx.snap +553 -0
- package/src/__snapshots__/Button.test.tsx.snap +1281 -0
- package/src/__snapshots__/Card.test.tsx.snap +195 -0
- package/src/__snapshots__/CheckBox.test.tsx.snap +190 -0
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +2299 -0
- package/src/__snapshots__/DataTable.test.tsx.snap +9614 -0
- package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +1719 -0
- package/src/__snapshots__/DismissButton.test.tsx.snap +91 -0
- package/src/__snapshots__/EmailField.test.tsx.snap +168 -0
- package/src/__snapshots__/ErrorBoundary.test.tsx.snap +57 -0
- package/src/__snapshots__/ErrorPage.test.tsx.snap +195 -0
- package/src/__snapshots__/Field.test.tsx.snap +4510 -0
- package/src/__snapshots__/Heading.test.tsx.snap +193 -0
- package/src/__snapshots__/HeightActionSheet.test.tsx.snap +1269 -0
- package/src/__snapshots__/Hyperlink.test.tsx.snap +81 -0
- package/src/__snapshots__/Icon.test.tsx.snap +47 -0
- package/src/__snapshots__/IconButton.test.tsx.snap +29 -0
- package/src/__snapshots__/Image.test.tsx.snap +282 -0
- package/src/__snapshots__/ImageBackground.test.tsx.snap +120 -0
- package/src/__snapshots__/InfoModalIcon.test.tsx.snap +1229 -0
- package/src/__snapshots__/InfoTooltipButton.test.tsx.snap +7 -0
- package/src/__snapshots__/Link.test.tsx.snap +41 -0
- package/src/__snapshots__/MarkdownView.test.tsx.snap +965 -0
- package/src/__snapshots__/Modal.test.tsx.snap +1477 -0
- package/src/__snapshots__/MultiselectField.test.tsx.snap +1454 -0
- package/src/__snapshots__/NumberField.test.tsx.snap +80 -0
- package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +5359 -0
- package/src/__snapshots__/OpenAPIContext.test.tsx.snap +14 -0
- package/src/__snapshots__/Page.test.tsx.snap +1647 -0
- package/src/__snapshots__/Pagination.test.tsx.snap +1913 -0
- package/src/__snapshots__/PasswordField.test.tsx.snap +15 -0
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +405 -0
- package/src/__snapshots__/PickerSelect.test.tsx.snap +266 -0
- package/src/__snapshots__/Radio.test.tsx.snap +111 -0
- package/src/__snapshots__/RadioField.test.tsx.snap +944 -0
- package/src/__snapshots__/SectionDivider.test.tsx.snap +37 -0
- package/src/__snapshots__/SegmentedControl.test.tsx.snap +1422 -0
- package/src/__snapshots__/SelectBadge.test.tsx.snap +2377 -0
- package/src/__snapshots__/SelectField.test.tsx.snap +1658 -0
- package/src/__snapshots__/SideDrawer.test.tsx.snap +1857 -0
- package/src/__snapshots__/SignatureField.test.tsx.snap +133 -0
- package/src/__snapshots__/Spinner.test.tsx.snap +73 -0
- package/src/__snapshots__/TapToEdit.test.tsx.snap +839 -0
- package/src/__snapshots__/TerrenoProvider.test.tsx.snap +203 -0
- package/src/__snapshots__/Text.test.tsx.snap +558 -0
- package/src/__snapshots__/TimezonePicker.test.tsx.snap +6676 -0
- package/src/__snapshots__/Toast.test.tsx.snap +1982 -0
- package/src/__snapshots__/Tooltip.test.tsx.snap +456 -0
- package/src/bunSetup.ts +101 -8
- package/src/fieldElements/FieldError.test.tsx +40 -0
- package/src/fieldElements/FieldHelperText.test.tsx +34 -0
- package/src/fieldElements/FieldTitle.test.tsx +30 -0
- package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +85 -0
- package/src/fieldElements/__snapshots__/FieldHelperText.test.tsx.snap +30 -0
- package/src/fieldElements/__snapshots__/FieldTitle.test.tsx.snap +19 -0
- package/src/icons/MobileIcon.test.tsx +21 -0
- package/src/icons/OfflineIcon.test.tsx +21 -0
- package/src/icons/OnlineIcon.test.tsx +21 -0
- package/src/icons/OutOfficeIcon.test.tsx +21 -0
- package/src/icons/__snapshots__/MobileIcon.test.tsx.snap +160 -0
- package/src/icons/__snapshots__/OfflineIcon.test.tsx.snap +133 -0
- package/src/icons/__snapshots__/OnlineIcon.test.tsx.snap +124 -0
- package/src/icons/__snapshots__/OutOfficeIcon.test.tsx.snap +160 -0
- package/src/table/Table.test.tsx +107 -0
- package/src/table/TableBadge.test.tsx +53 -0
- package/src/table/TableBoolean.test.tsx +38 -0
- package/src/table/TableDate.test.tsx +27 -0
- package/src/table/TableHeader.test.tsx +67 -0
- package/src/table/TableHeaderCell.test.tsx +113 -0
- package/src/table/TableIconButton.test.tsx +51 -0
- package/src/table/TableNumber.test.tsx +45 -0
- package/src/table/TableRow.test.tsx +83 -0
- package/src/table/TableText.test.tsx +30 -0
- package/src/table/TableTitle.test.tsx +30 -0
- package/src/table/__snapshots__/Table.test.tsx.snap +2090 -0
- package/src/table/__snapshots__/TableBadge.test.tsx.snap +710 -0
- package/src/table/__snapshots__/TableBoolean.test.tsx.snap +231 -0
- package/src/table/__snapshots__/TableDate.test.tsx.snap +61 -0
- package/src/table/__snapshots__/TableHeader.test.tsx.snap +1089 -0
- package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +1773 -0
- package/src/table/__snapshots__/TableIconButton.test.tsx.snap +81 -0
- package/src/table/__snapshots__/TableNumber.test.tsx.snap +91 -0
- package/src/table/__snapshots__/TableRow.test.tsx.snap +1391 -0
- package/src/table/__snapshots__/TableText.test.tsx.snap +73 -0
- package/src/table/__snapshots__/TableTitle.test.tsx.snap +109 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {SelectField} from "./SelectField";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("SelectField", () => {
|
|
7
|
+
const defaultOptions = [
|
|
8
|
+
{label: "Option 1", value: "opt1"},
|
|
9
|
+
{label: "Option 2", value: "opt2"},
|
|
10
|
+
{label: "Option 3", value: "opt3"},
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
it("renders correctly with default props", () => {
|
|
14
|
+
const {toJSON} = renderWithTheme(
|
|
15
|
+
<SelectField onChange={() => {}} options={defaultOptions} value="" />
|
|
16
|
+
);
|
|
17
|
+
expect(toJSON()).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("renders with title", () => {
|
|
21
|
+
const {getByText, toJSON} = renderWithTheme(
|
|
22
|
+
<SelectField onChange={() => {}} options={defaultOptions} title="Select an option" value="" />
|
|
23
|
+
);
|
|
24
|
+
expect(getByText("Select an option")).toBeTruthy();
|
|
25
|
+
expect(toJSON()).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("renders with helper text", () => {
|
|
29
|
+
const {getByText} = renderWithTheme(
|
|
30
|
+
<SelectField
|
|
31
|
+
helperText="This is helper text"
|
|
32
|
+
onChange={() => {}}
|
|
33
|
+
options={defaultOptions}
|
|
34
|
+
value=""
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
expect(getByText("This is helper text")).toBeTruthy();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("renders with error text", () => {
|
|
41
|
+
const {getByText} = renderWithTheme(
|
|
42
|
+
<SelectField
|
|
43
|
+
errorText="This field is required"
|
|
44
|
+
onChange={() => {}}
|
|
45
|
+
options={defaultOptions}
|
|
46
|
+
value=""
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
expect(getByText("This field is required")).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("renders with selected value", () => {
|
|
53
|
+
const {toJSON} = renderWithTheme(
|
|
54
|
+
<SelectField onChange={() => {}} options={defaultOptions} value="opt2" />
|
|
55
|
+
);
|
|
56
|
+
expect(toJSON()).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("renders with custom placeholder", () => {
|
|
60
|
+
const {toJSON} = renderWithTheme(
|
|
61
|
+
<SelectField
|
|
62
|
+
onChange={() => {}}
|
|
63
|
+
options={defaultOptions}
|
|
64
|
+
placeholder="Choose one..."
|
|
65
|
+
value=""
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
expect(toJSON()).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("renders disabled state", () => {
|
|
72
|
+
const {toJSON} = renderWithTheme(
|
|
73
|
+
<SelectField disabled onChange={() => {}} options={defaultOptions} value="" />
|
|
74
|
+
);
|
|
75
|
+
expect(toJSON()).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("renders with requireValue (no clear option)", () => {
|
|
79
|
+
const {toJSON} = renderWithTheme(
|
|
80
|
+
<SelectField onChange={() => {}} options={defaultOptions} requireValue value="opt1" />
|
|
81
|
+
);
|
|
82
|
+
expect(toJSON()).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {SideDrawer} from "./SideDrawer";
|
|
4
|
+
import {Text} from "./Text";
|
|
5
|
+
import {renderWithTheme} from "./test-utils";
|
|
6
|
+
|
|
7
|
+
describe("SideDrawer", () => {
|
|
8
|
+
it("renders correctly when closed", () => {
|
|
9
|
+
const {toJSON} = renderWithTheme(
|
|
10
|
+
<SideDrawer isOpen={false} renderContent={() => <Text>Drawer content</Text>}>
|
|
11
|
+
<Text>Main content</Text>
|
|
12
|
+
</SideDrawer>
|
|
13
|
+
);
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("renders correctly when open", () => {
|
|
18
|
+
const {toJSON} = renderWithTheme(
|
|
19
|
+
<SideDrawer isOpen={true} renderContent={() => <Text>Drawer content</Text>}>
|
|
20
|
+
<Text>Main content</Text>
|
|
21
|
+
</SideDrawer>
|
|
22
|
+
);
|
|
23
|
+
expect(toJSON()).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("renders with left position (default)", () => {
|
|
27
|
+
const {toJSON} = renderWithTheme(
|
|
28
|
+
<SideDrawer isOpen={true} position="left" renderContent={() => <Text>Left drawer</Text>}>
|
|
29
|
+
<Text>Content</Text>
|
|
30
|
+
</SideDrawer>
|
|
31
|
+
);
|
|
32
|
+
expect(toJSON()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("renders with right position", () => {
|
|
36
|
+
const {toJSON} = renderWithTheme(
|
|
37
|
+
<SideDrawer isOpen={true} position="right" renderContent={() => <Text>Right drawer</Text>}>
|
|
38
|
+
<Text>Content</Text>
|
|
39
|
+
</SideDrawer>
|
|
40
|
+
);
|
|
41
|
+
expect(toJSON()).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("renders with front drawer type (default)", () => {
|
|
45
|
+
const {toJSON} = renderWithTheme(
|
|
46
|
+
<SideDrawer drawerType="front" isOpen={true} renderContent={() => <Text>Front drawer</Text>}>
|
|
47
|
+
<Text>Content</Text>
|
|
48
|
+
</SideDrawer>
|
|
49
|
+
);
|
|
50
|
+
expect(toJSON()).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("renders with back drawer type", () => {
|
|
54
|
+
const {toJSON} = renderWithTheme(
|
|
55
|
+
<SideDrawer drawerType="back" isOpen={true} renderContent={() => <Text>Back drawer</Text>}>
|
|
56
|
+
<Text>Content</Text>
|
|
57
|
+
</SideDrawer>
|
|
58
|
+
);
|
|
59
|
+
expect(toJSON()).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("renders with slide drawer type", () => {
|
|
63
|
+
const {toJSON} = renderWithTheme(
|
|
64
|
+
<SideDrawer drawerType="slide" isOpen={true} renderContent={() => <Text>Slide drawer</Text>}>
|
|
65
|
+
<Text>Content</Text>
|
|
66
|
+
</SideDrawer>
|
|
67
|
+
);
|
|
68
|
+
expect(toJSON()).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("renders with custom drawer styles", () => {
|
|
72
|
+
const {toJSON} = renderWithTheme(
|
|
73
|
+
<SideDrawer
|
|
74
|
+
drawerStyles={{width: "50%"}}
|
|
75
|
+
isOpen={true}
|
|
76
|
+
renderContent={() => <Text>Styled drawer</Text>}
|
|
77
|
+
>
|
|
78
|
+
<Text>Content</Text>
|
|
79
|
+
</SideDrawer>
|
|
80
|
+
);
|
|
81
|
+
expect(toJSON()).toMatchSnapshot();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("accepts onOpen and onClose callbacks", () => {
|
|
85
|
+
const handleOpen = mock(() => {});
|
|
86
|
+
const handleClose = mock(() => {});
|
|
87
|
+
const {toJSON} = renderWithTheme(
|
|
88
|
+
<SideDrawer
|
|
89
|
+
isOpen={false}
|
|
90
|
+
onClose={handleClose}
|
|
91
|
+
onOpen={handleOpen}
|
|
92
|
+
renderContent={() => <Text>Drawer</Text>}
|
|
93
|
+
>
|
|
94
|
+
<Text>Content</Text>
|
|
95
|
+
</SideDrawer>
|
|
96
|
+
);
|
|
97
|
+
expect(toJSON()).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {Signature} from "./Signature";
|
|
4
|
+
|
|
5
|
+
describe("Signature", () => {
|
|
6
|
+
// Signature uses react-signature-canvas which requires a canvas/DOM environment
|
|
7
|
+
it.skip("renders correctly (skipped - requires canvas environment)", () => {
|
|
8
|
+
expect(Signature).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("component is defined", () => {
|
|
12
|
+
expect(Signature).toBeDefined();
|
|
13
|
+
expect(typeof Signature).toBe("function");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {SignatureField} from "./SignatureField";
|
|
4
|
+
|
|
5
|
+
describe("SignatureField", () => {
|
|
6
|
+
// SignatureField uses react-signature-canvas which requires a canvas/DOM environment
|
|
7
|
+
// that isn't available in the bun test environment
|
|
8
|
+
it.skip("renders correctly (skipped - requires canvas environment)", () => {
|
|
9
|
+
expect(SignatureField).toBeDefined();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("component is defined", () => {
|
|
13
|
+
expect(SignatureField).toBeDefined();
|
|
14
|
+
expect(typeof SignatureField).toBe("function");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {act} from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
import {Spinner} from "./Spinner";
|
|
5
|
+
import {renderWithTheme} from "./test-utils";
|
|
6
|
+
|
|
7
|
+
describe("Spinner", () => {
|
|
8
|
+
it("does not render immediately due to delay", () => {
|
|
9
|
+
const {toJSON} = renderWithTheme(<Spinner />);
|
|
10
|
+
// Spinner has a 300ms delay before showing
|
|
11
|
+
expect(toJSON()).toBeNull();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("renders after delay", async () => {
|
|
15
|
+
const {toJSON} = renderWithTheme(<Spinner />);
|
|
16
|
+
|
|
17
|
+
// Wait for the 300ms delay
|
|
18
|
+
await act(async () => {
|
|
19
|
+
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(toJSON()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("renders with small size", async () => {
|
|
26
|
+
const {toJSON} = renderWithTheme(<Spinner size="sm" />);
|
|
27
|
+
|
|
28
|
+
await act(async () => {
|
|
29
|
+
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(toJSON()).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("renders with large size", async () => {
|
|
36
|
+
const {toJSON} = renderWithTheme(<Spinner size="md" />);
|
|
37
|
+
|
|
38
|
+
await act(async () => {
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(toJSON()).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("renders with dark color", async () => {
|
|
46
|
+
const {toJSON} = renderWithTheme(<Spinner color="dark" />);
|
|
47
|
+
|
|
48
|
+
await act(async () => {
|
|
49
|
+
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(toJSON()).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("renders with accent color", async () => {
|
|
56
|
+
const {toJSON} = renderWithTheme(<Spinner color="accent" />);
|
|
57
|
+
|
|
58
|
+
await act(async () => {
|
|
59
|
+
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(toJSON()).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("renders with secondary color", async () => {
|
|
66
|
+
const {toJSON} = renderWithTheme(<Spinner color="secondary" />);
|
|
67
|
+
|
|
68
|
+
await act(async () => {
|
|
69
|
+
await new Promise((resolve) => setTimeout(resolve, 350));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(toJSON()).toMatchSnapshot();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {SplitPage} from "./SplitPage";
|
|
4
|
+
|
|
5
|
+
describe("SplitPage", () => {
|
|
6
|
+
// SplitPage uses react-native-swiper-flatlist and complex FlatList interactions
|
|
7
|
+
it.skip("renders correctly (skipped - uses react-native-swiper-flatlist)", () => {
|
|
8
|
+
expect(SplitPage).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("component is defined", () => {
|
|
12
|
+
expect(SplitPage).toBeDefined();
|
|
13
|
+
expect(typeof SplitPage).toBe("function");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {formatAddress, TapToEdit} from "./TapToEdit";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("TapToEdit", () => {
|
|
7
|
+
it("renders correctly with text value", () => {
|
|
8
|
+
const {toJSON} = renderWithTheme(
|
|
9
|
+
<TapToEdit setValue={() => {}} title="Name" value="John Doe" />
|
|
10
|
+
);
|
|
11
|
+
expect(toJSON()).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("displays title and value", () => {
|
|
15
|
+
const {getByText} = renderWithTheme(
|
|
16
|
+
<TapToEdit setValue={() => {}} title="Email" value="test@example.com" />
|
|
17
|
+
);
|
|
18
|
+
expect(getByText("Email")).toBeTruthy();
|
|
19
|
+
expect(getByText("test@example.com")).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("renders non-editable when editable is false", () => {
|
|
23
|
+
const {toJSON} = renderWithTheme(
|
|
24
|
+
<TapToEdit editable={false} title="Read Only" value="Cannot edit this" />
|
|
25
|
+
);
|
|
26
|
+
expect(toJSON()).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders edit icon when editable", () => {
|
|
30
|
+
const {toJSON} = renderWithTheme(
|
|
31
|
+
<TapToEdit editable setValue={() => {}} title="Editable Field" value="Click to edit" />
|
|
32
|
+
);
|
|
33
|
+
expect(toJSON()).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("shows editing mode when isEditing is true", () => {
|
|
37
|
+
const {toJSON} = renderWithTheme(
|
|
38
|
+
<TapToEdit isEditing setValue={() => {}} title="Field" value="Editing..." />
|
|
39
|
+
);
|
|
40
|
+
expect(toJSON()).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("displays helper text when provided", () => {
|
|
44
|
+
const {toJSON} = renderWithTheme(
|
|
45
|
+
<TapToEdit
|
|
46
|
+
helperText="Enter your full name"
|
|
47
|
+
onlyShowHelperTextWhileEditing={false}
|
|
48
|
+
setValue={() => {}}
|
|
49
|
+
title="Name"
|
|
50
|
+
value=""
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
expect(toJSON()).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("renders with boolean type showing Yes/No", () => {
|
|
57
|
+
const {getByText} = renderWithTheme(
|
|
58
|
+
<TapToEdit editable={false} title="Active" type="boolean" value={true} />
|
|
59
|
+
);
|
|
60
|
+
expect(getByText("Yes")).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("renders with boolean type showing No when false", () => {
|
|
64
|
+
const {getByText} = renderWithTheme(
|
|
65
|
+
<TapToEdit editable={false} title="Active" type="boolean" value={false} />
|
|
66
|
+
);
|
|
67
|
+
expect(getByText("No")).toBeTruthy();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("renders with transform function", () => {
|
|
71
|
+
const {getByText} = renderWithTheme(
|
|
72
|
+
<TapToEdit
|
|
73
|
+
editable={false}
|
|
74
|
+
title="Custom"
|
|
75
|
+
transform={(val) => `Transformed: ${val}`}
|
|
76
|
+
value="data"
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
expect(getByText("Transformed: data")).toBeTruthy();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("renders with textarea type", () => {
|
|
83
|
+
const {toJSON} = renderWithTheme(
|
|
84
|
+
<TapToEdit
|
|
85
|
+
editable={false}
|
|
86
|
+
title="Description"
|
|
87
|
+
type="textarea"
|
|
88
|
+
value="This is a long description that spans multiple lines."
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
expect(toJSON()).toMatchSnapshot();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("formatAddress", () => {
|
|
96
|
+
it("formats full address correctly", () => {
|
|
97
|
+
const address = {
|
|
98
|
+
address1: "123 Main St",
|
|
99
|
+
address2: "Apt 4",
|
|
100
|
+
city: "New York",
|
|
101
|
+
state: "NY",
|
|
102
|
+
zipcode: "10001",
|
|
103
|
+
};
|
|
104
|
+
const result = formatAddress(address);
|
|
105
|
+
expect(result).toContain("123 Main St");
|
|
106
|
+
expect(result).toContain("Apt 4");
|
|
107
|
+
expect(result).toContain("New York");
|
|
108
|
+
expect(result).toContain("NY");
|
|
109
|
+
expect(result).toContain("10001");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("formats address as string when asString is true", () => {
|
|
113
|
+
const address = {
|
|
114
|
+
address1: "123 Main St",
|
|
115
|
+
city: "Boston",
|
|
116
|
+
state: "MA",
|
|
117
|
+
zipcode: "02101",
|
|
118
|
+
};
|
|
119
|
+
const result = formatAddress(address, true);
|
|
120
|
+
expect(result).toContain(",");
|
|
121
|
+
expect(result).not.toContain("\n");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("handles partial address", () => {
|
|
125
|
+
const address = {
|
|
126
|
+
city: "Chicago",
|
|
127
|
+
state: "IL",
|
|
128
|
+
};
|
|
129
|
+
const result = formatAddress(address);
|
|
130
|
+
expect(result).toContain("Chicago");
|
|
131
|
+
expect(result).toContain("IL");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("includes county information when provided", () => {
|
|
135
|
+
const address = {
|
|
136
|
+
address1: "100 County Rd",
|
|
137
|
+
city: "Rural Town",
|
|
138
|
+
countyCode: "113",
|
|
139
|
+
countyName: "Dallas County",
|
|
140
|
+
state: "TX",
|
|
141
|
+
zipcode: "75001",
|
|
142
|
+
};
|
|
143
|
+
const result = formatAddress(address);
|
|
144
|
+
expect(result).toContain("Dallas County");
|
|
145
|
+
expect(result).toContain("(113)");
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {render} from "@testing-library/react-native";
|
|
3
|
+
import {Text, View} from "react-native";
|
|
4
|
+
|
|
5
|
+
import {TerrenoProvider} from "./TerrenoProvider";
|
|
6
|
+
|
|
7
|
+
describe("TerrenoProvider", () => {
|
|
8
|
+
it("renders children correctly", () => {
|
|
9
|
+
const {getByText} = render(
|
|
10
|
+
<TerrenoProvider>
|
|
11
|
+
<Text>Child content</Text>
|
|
12
|
+
</TerrenoProvider>
|
|
13
|
+
);
|
|
14
|
+
expect(getByText("Child content")).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("renders correctly with default props", () => {
|
|
18
|
+
const {toJSON} = render(
|
|
19
|
+
<TerrenoProvider>
|
|
20
|
+
<View>
|
|
21
|
+
<Text>App content</Text>
|
|
22
|
+
</View>
|
|
23
|
+
</TerrenoProvider>
|
|
24
|
+
);
|
|
25
|
+
expect(toJSON()).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("renders with openAPISpecUrl", () => {
|
|
29
|
+
const {toJSON} = render(
|
|
30
|
+
<TerrenoProvider openAPISpecUrl="https://api.example.com/openapi.json">
|
|
31
|
+
<Text>Content</Text>
|
|
32
|
+
</TerrenoProvider>
|
|
33
|
+
);
|
|
34
|
+
expect(toJSON()).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {describe, expect, it, spyOn} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {Text} from "./Text";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("Text", () => {
|
|
7
|
+
it("renders correctly with default props", () => {
|
|
8
|
+
const {toJSON} = renderWithTheme(<Text>Hello World</Text>);
|
|
9
|
+
expect(toJSON()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("renders text content correctly", () => {
|
|
13
|
+
const {getByText} = renderWithTheme(<Text>Test content</Text>);
|
|
14
|
+
expect(getByText("Test content")).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Size tests
|
|
18
|
+
it("renders with sm size", () => {
|
|
19
|
+
const {toJSON} = renderWithTheme(<Text size="sm">Small text</Text>);
|
|
20
|
+
expect(toJSON()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("renders with md size (default)", () => {
|
|
24
|
+
const {toJSON} = renderWithTheme(<Text size="md">Medium text</Text>);
|
|
25
|
+
expect(toJSON()).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("renders with lg size", () => {
|
|
29
|
+
const {toJSON} = renderWithTheme(<Text size="lg">Large text</Text>);
|
|
30
|
+
expect(toJSON()).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("renders with xl size", () => {
|
|
34
|
+
const {toJSON} = renderWithTheme(<Text size="xl">Extra large text</Text>);
|
|
35
|
+
expect(toJSON()).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("renders with 2xl size", () => {
|
|
39
|
+
const {toJSON} = renderWithTheme(<Text size="2xl">2XL text</Text>);
|
|
40
|
+
expect(toJSON()).toMatchSnapshot();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Style tests
|
|
44
|
+
it("renders bold text", () => {
|
|
45
|
+
const {toJSON} = renderWithTheme(<Text bold>Bold text</Text>);
|
|
46
|
+
expect(toJSON()).toMatchSnapshot();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("renders italic text", () => {
|
|
50
|
+
const {toJSON} = renderWithTheme(<Text italic>Italic text</Text>);
|
|
51
|
+
expect(toJSON()).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("renders bold italic text", () => {
|
|
55
|
+
const {toJSON} = renderWithTheme(
|
|
56
|
+
<Text bold italic>
|
|
57
|
+
Bold italic text
|
|
58
|
+
</Text>
|
|
59
|
+
);
|
|
60
|
+
expect(toJSON()).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("renders underlined text", () => {
|
|
64
|
+
const {toJSON} = renderWithTheme(<Text underline>Underlined text</Text>);
|
|
65
|
+
expect(toJSON()).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Alignment tests
|
|
69
|
+
it("renders with left alignment (default)", () => {
|
|
70
|
+
const {toJSON} = renderWithTheme(<Text align="left">Left aligned</Text>);
|
|
71
|
+
expect(toJSON()).toMatchSnapshot();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("renders with center alignment", () => {
|
|
75
|
+
const {toJSON} = renderWithTheme(<Text align="center">Centered</Text>);
|
|
76
|
+
expect(toJSON()).toMatchSnapshot();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("renders with right alignment", () => {
|
|
80
|
+
const {toJSON} = renderWithTheme(<Text align="right">Right aligned</Text>);
|
|
81
|
+
expect(toJSON()).toMatchSnapshot();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Color tests
|
|
85
|
+
it("renders with secondary color", () => {
|
|
86
|
+
const {toJSON} = renderWithTheme(<Text color="secondary">Secondary color</Text>);
|
|
87
|
+
expect(toJSON()).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("renders with accent color", () => {
|
|
91
|
+
const {toJSON} = renderWithTheme(<Text color="accent">Accent color</Text>);
|
|
92
|
+
expect(toJSON()).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("renders with link color", () => {
|
|
96
|
+
const {toJSON} = renderWithTheme(<Text color="link">Link color</Text>);
|
|
97
|
+
expect(toJSON()).toMatchSnapshot();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Truncation tests
|
|
101
|
+
it("renders with truncate", () => {
|
|
102
|
+
const {toJSON} = renderWithTheme(
|
|
103
|
+
<Text truncate>This is a long text that should be truncated</Text>
|
|
104
|
+
);
|
|
105
|
+
expect(toJSON()).toMatchSnapshot();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("renders with numberOfLines", () => {
|
|
109
|
+
const {toJSON} = renderWithTheme(<Text numberOfLines={2}>Multiple lines of text</Text>);
|
|
110
|
+
expect(toJSON()).toMatchSnapshot();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("logs error when truncate and numberOfLines > 1 are both set", () => {
|
|
114
|
+
const consoleErrorSpy = spyOn(console, "error").mockImplementation(() => {});
|
|
115
|
+
|
|
116
|
+
renderWithTheme(
|
|
117
|
+
<Text numberOfLines={3} truncate>
|
|
118
|
+
Invalid combination
|
|
119
|
+
</Text>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith("Cannot truncate Text and have 3 lines");
|
|
123
|
+
|
|
124
|
+
consoleErrorSpy.mockRestore();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// skipLinking tests
|
|
128
|
+
it("renders with skipLinking", () => {
|
|
129
|
+
const {toJSON} = renderWithTheme(<Text skipLinking>No hyperlinks</Text>);
|
|
130
|
+
expect(toJSON()).toMatchSnapshot();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("renders with testID", () => {
|
|
134
|
+
const {getByTestId} = renderWithTheme(<Text testID="test-text">Test</Text>);
|
|
135
|
+
expect(getByTestId("test-text")).toBeTruthy();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Combined style tests
|
|
139
|
+
it("renders with multiple style props", () => {
|
|
140
|
+
const {toJSON} = renderWithTheme(
|
|
141
|
+
<Text align="center" bold color="accent" size="lg" underline>
|
|
142
|
+
Styled text
|
|
143
|
+
</Text>
|
|
144
|
+
);
|
|
145
|
+
expect(toJSON()).toMatchSnapshot();
|
|
146
|
+
});
|
|
147
|
+
});
|