@terreno/ui 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Button.js +7 -9
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +39 -0
- package/dist/DateUtilities.js +2 -2
- package/dist/UserInactivity.d.ts +28 -0
- package/dist/UserInactivity.js +100 -0
- package/dist/UserInactivity.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- 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/Button.tsx +20 -37
- package/src/Card.test.tsx +61 -0
- package/src/CheckBox.test.tsx +53 -0
- package/src/Common.ts +45 -0
- package/src/CustomSelectField.test.tsx +85 -0
- package/src/DataTable.test.tsx +133 -0
- package/src/DateTimeActionSheet.test.tsx +65 -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 +58 -0
- package/src/Modal.test.tsx +169 -0
- package/src/ModalSheet.test.tsx +52 -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 +52 -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 +32 -0
- package/src/SignatureField.test.tsx +60 -0
- package/src/Spinner.test.tsx +74 -0
- package/src/SplitPage.test.tsx +82 -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 +53 -0
- package/src/UserInactivity.test.tsx +96 -0
- package/src/UserInactivity.tsx +129 -0
- package/src/Utilities.test.tsx +237 -0
- package/src/WebAddressAutocomplete.test.tsx +33 -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 +934 -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__/DateTimeActionSheet.test.tsx.snap +11 -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__/MobileAddressAutoComplete.test.tsx.snap +230 -0
- package/src/__snapshots__/Modal.test.tsx.snap +1477 -0
- package/src/__snapshots__/ModalSheet.test.tsx.snap +37 -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 +1053 -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__/Signature.test.tsx.snap +67 -0
- package/src/__snapshots__/SignatureField.test.tsx.snap +241 -0
- package/src/__snapshots__/Spinner.test.tsx.snap +73 -0
- package/src/__snapshots__/SplitPage.test.tsx.snap +686 -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/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +377 -0
- package/src/__snapshots__/UserInactivity.test.tsx.snap +108 -0
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +238 -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/index.tsx +1 -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,79 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {PhoneNumberField} from "./PhoneNumberField";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("PhoneNumberField", () => {
|
|
7
|
+
it("renders correctly with default props", () => {
|
|
8
|
+
const {toJSON} = renderWithTheme(
|
|
9
|
+
<PhoneNumberField label="Phone" onChange={() => {}} value="" />
|
|
10
|
+
);
|
|
11
|
+
expect(toJSON()).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("renders with placeholder", () => {
|
|
15
|
+
const {getByPlaceholderText} = renderWithTheme(
|
|
16
|
+
<PhoneNumberField
|
|
17
|
+
label="Phone"
|
|
18
|
+
onChange={() => {}}
|
|
19
|
+
placeholder="Enter phone number"
|
|
20
|
+
value=""
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
expect(getByPlaceholderText("Enter phone number")).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("renders with initial value", () => {
|
|
27
|
+
const {getByDisplayValue} = renderWithTheme(
|
|
28
|
+
<PhoneNumberField label="Phone" onChange={() => {}} value="(555) 123-4567" />
|
|
29
|
+
);
|
|
30
|
+
expect(getByDisplayValue("(555) 123-4567")).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("formats phone number as user types", () => {
|
|
34
|
+
const handleChange = mock((_value: string) => {});
|
|
35
|
+
const {toJSON} = renderWithTheme(
|
|
36
|
+
<PhoneNumberField label="Phone" onChange={handleChange} value="5551234567" />
|
|
37
|
+
);
|
|
38
|
+
// Snapshot captures the formatted phone number display
|
|
39
|
+
expect(toJSON()).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("renders with custom errorText", () => {
|
|
43
|
+
const {getByText} = renderWithTheme(
|
|
44
|
+
<PhoneNumberField
|
|
45
|
+
errorText="Phone number is required"
|
|
46
|
+
label="Phone"
|
|
47
|
+
onChange={() => {}}
|
|
48
|
+
value=""
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
expect(getByText("Phone number is required")).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("renders with icon", () => {
|
|
55
|
+
const {toJSON} = renderWithTheme(
|
|
56
|
+
<PhoneNumberField iconName="phone" label="Phone" onChange={() => {}} value="" />
|
|
57
|
+
);
|
|
58
|
+
expect(toJSON()).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("uses US as default country code", () => {
|
|
62
|
+
const {toJSON} = renderWithTheme(
|
|
63
|
+
<PhoneNumberField label="Phone" onChange={() => {}} value="5551234567" />
|
|
64
|
+
);
|
|
65
|
+
expect(toJSON()).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("accepts custom country code", () => {
|
|
69
|
+
const {toJSON} = renderWithTheme(
|
|
70
|
+
<PhoneNumberField
|
|
71
|
+
defaultCountryCode="GB"
|
|
72
|
+
label="Phone"
|
|
73
|
+
onChange={() => {}}
|
|
74
|
+
value="7911123456"
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
expect(toJSON()).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {RNPickerSelect} from "./PickerSelect";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
// Note: @react-native-picker/picker is mocked globally in bunSetup.ts
|
|
7
|
+
|
|
8
|
+
describe("PickerSelect", () => {
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
items: [
|
|
11
|
+
{label: "Option 1", value: "1"},
|
|
12
|
+
{label: "Option 2", value: "2"},
|
|
13
|
+
{label: "Option 3", value: "3"},
|
|
14
|
+
],
|
|
15
|
+
onValueChange: () => {},
|
|
16
|
+
placeholder: {label: "Select an option", value: ""},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it("renders correctly with default props", () => {
|
|
20
|
+
const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} />);
|
|
21
|
+
expect(toJSON()).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("component is defined", () => {
|
|
25
|
+
expect(RNPickerSelect).toBeDefined();
|
|
26
|
+
expect(typeof RNPickerSelect).toBe("function");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders with selected value", () => {
|
|
30
|
+
const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} value="2" />);
|
|
31
|
+
expect(toJSON()).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("renders disabled state", () => {
|
|
35
|
+
const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} disabled />);
|
|
36
|
+
expect(toJSON()).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("renders without placeholder when placeholder is empty object", () => {
|
|
40
|
+
const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} placeholder={{}} />);
|
|
41
|
+
expect(toJSON()).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("calls onValueChange when value changes", () => {
|
|
45
|
+
const mockOnValueChange = mock(() => {});
|
|
46
|
+
renderWithTheme(
|
|
47
|
+
<RNPickerSelect {...defaultProps} onValueChange={mockOnValueChange} value="1" />
|
|
48
|
+
);
|
|
49
|
+
// The component is rendered, onValueChange would be called on user interaction
|
|
50
|
+
expect(mockOnValueChange).toBeDefined();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {Radio} from "./Radio";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("Radio", () => {
|
|
7
|
+
it("renders correctly when not selected", () => {
|
|
8
|
+
const {toJSON} = renderWithTheme(<Radio selected={false} />);
|
|
9
|
+
expect(toJSON()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("renders correctly when selected", () => {
|
|
13
|
+
const {toJSON} = renderWithTheme(<Radio selected />);
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("shows inner circle when selected", () => {
|
|
18
|
+
const {toJSON} = renderWithTheme(<Radio selected />);
|
|
19
|
+
const snapshot = toJSON();
|
|
20
|
+
// Should have nested View for the inner filled circle
|
|
21
|
+
expect(snapshot).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("does not show inner circle when not selected", () => {
|
|
25
|
+
const {toJSON} = renderWithTheme(<Radio selected={false} />);
|
|
26
|
+
const snapshot = toJSON();
|
|
27
|
+
// Should only have outer circle, no inner content
|
|
28
|
+
expect(snapshot).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
import {RadioField} from "./RadioField";
|
|
5
|
+
import {renderWithTheme} from "./test-utils";
|
|
6
|
+
|
|
7
|
+
describe("RadioField", () => {
|
|
8
|
+
const defaultOptions = [
|
|
9
|
+
{label: "Option A", value: "a"},
|
|
10
|
+
{label: "Option B", value: "b"},
|
|
11
|
+
{label: "Option C", value: "c"},
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
it("renders correctly with default props", () => {
|
|
15
|
+
const {toJSON} = renderWithTheme(
|
|
16
|
+
<RadioField onChange={() => {}} options={defaultOptions} title="Select one" value="" />
|
|
17
|
+
);
|
|
18
|
+
expect(toJSON()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("renders title correctly", () => {
|
|
22
|
+
const {getByText} = renderWithTheme(
|
|
23
|
+
<RadioField onChange={() => {}} options={defaultOptions} title="Choose an option" value="" />
|
|
24
|
+
);
|
|
25
|
+
expect(getByText("Choose an option")).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("renders all options", () => {
|
|
29
|
+
const {getByText} = renderWithTheme(
|
|
30
|
+
<RadioField onChange={() => {}} options={defaultOptions} title="Title" value="" />
|
|
31
|
+
);
|
|
32
|
+
expect(getByText("Option A")).toBeTruthy();
|
|
33
|
+
expect(getByText("Option B")).toBeTruthy();
|
|
34
|
+
expect(getByText("Option C")).toBeTruthy();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("shows selected option", () => {
|
|
38
|
+
const {toJSON} = renderWithTheme(
|
|
39
|
+
<RadioField onChange={() => {}} options={defaultOptions} title="Title" value="b" />
|
|
40
|
+
);
|
|
41
|
+
expect(toJSON()).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("calls onChange when option is selected", () => {
|
|
45
|
+
const handleChange = mock((_value: string) => {});
|
|
46
|
+
const {getByText} = renderWithTheme(
|
|
47
|
+
<RadioField onChange={handleChange} options={defaultOptions} title="Title" value="" />
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
fireEvent.press(getByText("Option B"));
|
|
51
|
+
expect(handleChange).toHaveBeenCalledWith("b");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("renders with rightText variant (default)", () => {
|
|
55
|
+
const {toJSON} = renderWithTheme(
|
|
56
|
+
<RadioField
|
|
57
|
+
onChange={() => {}}
|
|
58
|
+
options={defaultOptions}
|
|
59
|
+
title="Title"
|
|
60
|
+
value=""
|
|
61
|
+
variant="rightText"
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
expect(toJSON()).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("renders with leftText variant", () => {
|
|
68
|
+
const {toJSON} = renderWithTheme(
|
|
69
|
+
<RadioField
|
|
70
|
+
onChange={() => {}}
|
|
71
|
+
options={defaultOptions}
|
|
72
|
+
title="Title"
|
|
73
|
+
value=""
|
|
74
|
+
variant="leftText"
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
expect(toJSON()).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("renders options using value when label is not provided", () => {
|
|
81
|
+
const optionsWithoutLabels = [{value: "first"}, {value: "second"}, {value: "third"}];
|
|
82
|
+
const {getByText} = renderWithTheme(
|
|
83
|
+
<RadioField onChange={() => {}} options={optionsWithoutLabels} title="Title" value="" />
|
|
84
|
+
);
|
|
85
|
+
expect(getByText("first")).toBeTruthy();
|
|
86
|
+
expect(getByText("second")).toBeTruthy();
|
|
87
|
+
expect(getByText("third")).toBeTruthy();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {SectionDivider} from "./SectionDivider";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("SectionDivider", () => {
|
|
7
|
+
it("renders correctly", () => {
|
|
8
|
+
const {toJSON} = renderWithTheme(<SectionDivider />);
|
|
9
|
+
expect(toJSON()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("is hidden from accessibility", () => {
|
|
13
|
+
const {toJSON} = renderWithTheme(<SectionDivider />);
|
|
14
|
+
// The component should have aria-hidden=true
|
|
15
|
+
expect(toJSON()).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
import {SegmentedControl} from "./SegmentedControl";
|
|
5
|
+
import {renderWithTheme} from "./test-utils";
|
|
6
|
+
|
|
7
|
+
describe("SegmentedControl", () => {
|
|
8
|
+
const defaultItems = ["Tab 1", "Tab 2", "Tab 3"];
|
|
9
|
+
|
|
10
|
+
it("renders correctly with default props", () => {
|
|
11
|
+
const {toJSON} = renderWithTheme(<SegmentedControl items={defaultItems} selectedIndex={0} />);
|
|
12
|
+
expect(toJSON()).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("renders all items", () => {
|
|
16
|
+
const {getByText} = renderWithTheme(
|
|
17
|
+
<SegmentedControl items={defaultItems} selectedIndex={0} />
|
|
18
|
+
);
|
|
19
|
+
expect(getByText("Tab 1")).toBeTruthy();
|
|
20
|
+
expect(getByText("Tab 2")).toBeTruthy();
|
|
21
|
+
expect(getByText("Tab 3")).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("highlights selected item", () => {
|
|
25
|
+
const {toJSON} = renderWithTheme(<SegmentedControl items={defaultItems} selectedIndex={1} />);
|
|
26
|
+
expect(toJSON()).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("calls onChange when item is pressed", () => {
|
|
30
|
+
const handleChange = mock((_index: number) => {});
|
|
31
|
+
const {getByText} = renderWithTheme(
|
|
32
|
+
<SegmentedControl items={defaultItems} onChange={handleChange} selectedIndex={0} />
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
fireEvent.press(getByText("Tab 2"));
|
|
36
|
+
expect(handleChange).toHaveBeenCalledWith(1);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("renders with medium size (default)", () => {
|
|
40
|
+
const {toJSON} = renderWithTheme(
|
|
41
|
+
<SegmentedControl items={defaultItems} selectedIndex={0} size="md" />
|
|
42
|
+
);
|
|
43
|
+
expect(toJSON()).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("renders with large size", () => {
|
|
47
|
+
const {toJSON} = renderWithTheme(
|
|
48
|
+
<SegmentedControl items={defaultItems} selectedIndex={0} size="lg" />
|
|
49
|
+
);
|
|
50
|
+
expect(toJSON()).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("renders with badges", () => {
|
|
54
|
+
const badges = [
|
|
55
|
+
{count: 5, status: "info" as const},
|
|
56
|
+
{count: 3, status: "warning" as const},
|
|
57
|
+
{count: 1, status: "error" as const},
|
|
58
|
+
];
|
|
59
|
+
const {toJSON} = renderWithTheme(
|
|
60
|
+
<SegmentedControl badges={badges} items={defaultItems} selectedIndex={0} />
|
|
61
|
+
);
|
|
62
|
+
expect(toJSON()).toMatchSnapshot();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("renders with maxItems and scroll buttons", () => {
|
|
66
|
+
const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
|
|
67
|
+
const {toJSON} = renderWithTheme(
|
|
68
|
+
<SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
|
|
69
|
+
);
|
|
70
|
+
expect(toJSON()).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("handles scroll navigation", () => {
|
|
74
|
+
const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
|
|
75
|
+
const {getByText, toJSON} = renderWithTheme(
|
|
76
|
+
<SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
|
|
77
|
+
);
|
|
78
|
+
// Initially shows first 3 items
|
|
79
|
+
expect(getByText("Tab 1")).toBeTruthy();
|
|
80
|
+
expect(getByText("Tab 2")).toBeTruthy();
|
|
81
|
+
expect(getByText("Tab 3")).toBeTruthy();
|
|
82
|
+
expect(toJSON()).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {describe, expect, it} from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {SelectBadge} from "./SelectBadge";
|
|
4
|
+
import {renderWithTheme} from "./test-utils";
|
|
5
|
+
|
|
6
|
+
describe("SelectBadge", () => {
|
|
7
|
+
const defaultOptions = [
|
|
8
|
+
{label: "Option A", value: "a"},
|
|
9
|
+
{label: "Option B", value: "b"},
|
|
10
|
+
{label: "Option C", value: "c"},
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
it("renders correctly with default props", () => {
|
|
14
|
+
const {toJSON} = renderWithTheme(
|
|
15
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} value="a" />
|
|
16
|
+
);
|
|
17
|
+
expect(toJSON()).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("displays selected option label", () => {
|
|
21
|
+
const {getByText} = renderWithTheme(
|
|
22
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} value="b" />
|
|
23
|
+
);
|
|
24
|
+
expect(getByText("Option B")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("displays placeholder when no value", () => {
|
|
28
|
+
const {getByText} = renderWithTheme(
|
|
29
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} value={undefined as any} />
|
|
30
|
+
);
|
|
31
|
+
expect(getByText("---")).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("renders with info status (default)", () => {
|
|
35
|
+
const {toJSON} = renderWithTheme(
|
|
36
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} status="info" value="a" />
|
|
37
|
+
);
|
|
38
|
+
expect(toJSON()).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("renders with success status", () => {
|
|
42
|
+
const {toJSON} = renderWithTheme(
|
|
43
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} status="success" value="a" />
|
|
44
|
+
);
|
|
45
|
+
expect(toJSON()).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("renders with warning status", () => {
|
|
49
|
+
const {toJSON} = renderWithTheme(
|
|
50
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} status="warning" value="a" />
|
|
51
|
+
);
|
|
52
|
+
expect(toJSON()).toMatchSnapshot();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("renders with error status", () => {
|
|
56
|
+
const {toJSON} = renderWithTheme(
|
|
57
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} status="error" value="a" />
|
|
58
|
+
);
|
|
59
|
+
expect(toJSON()).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("renders with neutral status", () => {
|
|
63
|
+
const {toJSON} = renderWithTheme(
|
|
64
|
+
<SelectBadge onChange={() => {}} options={defaultOptions} status="neutral" value="a" />
|
|
65
|
+
);
|
|
66
|
+
expect(toJSON()).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("renders with secondary style", () => {
|
|
70
|
+
const {toJSON} = renderWithTheme(
|
|
71
|
+
<SelectBadge
|
|
72
|
+
onChange={() => {}}
|
|
73
|
+
options={defaultOptions}
|
|
74
|
+
secondary
|
|
75
|
+
status="success"
|
|
76
|
+
value="a"
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
expect(toJSON()).toMatchSnapshot();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("renders with custom colors", () => {
|
|
83
|
+
const {toJSON} = renderWithTheme(
|
|
84
|
+
<SelectBadge
|
|
85
|
+
customBackgroundColor="#FF0000"
|
|
86
|
+
customBorderColor="#00FF00"
|
|
87
|
+
customTextColor="#0000FF"
|
|
88
|
+
onChange={() => {}}
|
|
89
|
+
options={defaultOptions}
|
|
90
|
+
status="custom"
|
|
91
|
+
value="a"
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
expect(toJSON()).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("renders disabled state", () => {
|
|
98
|
+
const {toJSON} = renderWithTheme(
|
|
99
|
+
<SelectBadge disabled onChange={() => {}} options={defaultOptions} value="a" />
|
|
100
|
+
);
|
|
101
|
+
expect(toJSON()).toMatchSnapshot();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -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,32 @@
|
|
|
1
|
+
import {describe, expect, it, mock} from "bun:test";
|
|
2
|
+
import {forwardRef} from "react";
|
|
3
|
+
import {View} from "react-native";
|
|
4
|
+
|
|
5
|
+
import {Signature} from "./Signature";
|
|
6
|
+
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
|
|
8
|
+
// Mock react-signature-canvas
|
|
9
|
+
mock.module("react-signature-canvas", () => ({
|
|
10
|
+
default: forwardRef(({backgroundColor}: any, ref) => (
|
|
11
|
+
<View ref={ref as any} style={{backgroundColor}} testID="signature-canvas" />
|
|
12
|
+
)),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
describe("Signature", () => {
|
|
16
|
+
it("renders correctly", () => {
|
|
17
|
+
const mockOnChange = mock(() => {});
|
|
18
|
+
const {toJSON} = renderWithTheme(<Signature onChange={mockOnChange} />);
|
|
19
|
+
expect(toJSON()).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("component is defined", () => {
|
|
23
|
+
expect(Signature).toBeDefined();
|
|
24
|
+
expect(typeof Signature).toBe("function");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("renders with clear button", () => {
|
|
28
|
+
const mockOnChange = mock(() => {});
|
|
29
|
+
const {getByText} = renderWithTheme(<Signature onChange={mockOnChange} />);
|
|
30
|
+
expect(getByText("Clear")).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
});
|