@jobber/components-native 0.101.3 → 0.101.4
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/package.json +19 -11
- package/dist/src/ActionItem/ActionItem.test.js +81 -0
- package/dist/src/ActionItem/ActionItemGroup.test.js +25 -0
- package/dist/src/ActionItem/components/ActionItemContainer.test.js +24 -0
- package/dist/src/ActionLabel/ActionLabel.test.js +81 -0
- package/dist/src/ActivityIndicator/ActivityIndicator.test.js +23 -0
- package/dist/src/AtlantisContext/AtlantisContext.test.js +35 -0
- package/dist/src/AtlantisThemeContext/AtlantisThemeContext.test.js +65 -0
- package/dist/src/AtlantisThemeContext/buildThemedStyles.test.js +43 -0
- package/dist/src/AutoLink/AutoLink.test.js +133 -0
- package/dist/src/AutoLink/components/Link/Link.test.js +18 -0
- package/dist/src/Banner/Banner.test.js +98 -0
- package/dist/src/BottomSheet/BottomSheet.test.js +105 -0
- package/dist/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.test.js +19 -0
- package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.test.js +68 -0
- package/dist/src/Button/Button.test.js +228 -0
- package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.test.js +25 -0
- package/dist/src/ButtonGroup/ButtonGroup.test.js +153 -0
- package/dist/src/Card/Card.test.js +80 -0
- package/dist/src/Card/components/InternalCardHeader.test.js +18 -0
- package/dist/src/Checkbox/Checkbox.test.js +135 -0
- package/dist/src/Checkbox/CheckboxGroup.test.js +197 -0
- package/dist/src/Checkbox/CheckboxGroupReducer.test.js +25 -0
- package/dist/src/Chip/Chip.test.js +69 -0
- package/dist/src/Content/Content.test.js +250 -0
- package/dist/src/ContentOverlay/ContentOverlay.test.js +297 -0
- package/dist/src/ContentOverlay/computeContentOverlayBehavior.test.js +197 -0
- package/dist/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.test.js +62 -0
- package/dist/src/ContentOverlay/hooks/useKeyboardVisibility.test.js +41 -0
- package/dist/src/ContentOverlay/hooks/useViewLayoutHeight.test.js +62 -0
- package/dist/src/Disclosure/Disclosure.test.js +64 -0
- package/dist/src/Divider/Divider.test.js +65 -0
- package/dist/src/EmptyState/EmptyState.test.js +82 -0
- package/dist/src/ErrorMessageWrapper/ErrorMessageWrapper.test.js +29 -0
- package/dist/src/Flex/Flex.test.js +104 -0
- package/dist/src/Form/Form.test.js +393 -0
- package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.test.js +41 -0
- package/dist/src/Form/components/FormMessage/FormMessage.test.js +73 -0
- package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.test.js +30 -0
- package/dist/src/Form/components/FormSaveButton/FormSaveButton.test.js +82 -0
- package/dist/src/Form/context/AtlantisFormContext.test.js +28 -0
- package/dist/src/Form/hooks/useScrollToError/useScrollToError.test.js +89 -0
- package/dist/src/FormField/FormField.test.js +81 -0
- package/dist/src/FormatFile/FormatFile.test.js +212 -0
- package/dist/src/FormatFile/FormatFileThumbnail.test.js +192 -0
- package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.js +74 -0
- package/dist/src/FormatFile/components/MediaView/MediaView.test.js +202 -0
- package/dist/src/FormatFile/utils/parseFile.test.js +188 -0
- package/dist/src/Glimmer/Glimmer.test.js +61 -0
- package/dist/src/Heading/Heading.test.js +61 -0
- package/dist/src/Icon/Icon.test.js +40 -0
- package/dist/src/IconButton/IconButton.test.js +38 -0
- package/dist/src/InputCurrency/InputCurrency.test.js +106 -0
- package/dist/src/InputDate/InputDate.test.js +184 -0
- package/dist/src/InputEmail/InputEmail.test.js +27 -0
- package/dist/src/InputFieldWrapper/InputFieldWrapper.test.js +279 -0
- package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.test.js +9 -0
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.test.js +130 -0
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.test.js +51 -0
- package/dist/src/InputNumber/InputNumber.test.js +220 -0
- package/dist/src/InputPassword/InputPassword.test.js +63 -0
- package/dist/src/InputPressable/InputPressable.test.js +138 -0
- package/dist/src/InputSearch/InputSearch.test.js +54 -0
- package/dist/src/InputText/InputText.test.js +652 -0
- package/dist/src/InputText/context/InputAccessoriesProvider.test.js +71 -0
- package/dist/src/InputTime/InputTime.test.js +199 -0
- package/dist/src/InputTime/utils/utils.test.js +32 -0
- package/dist/src/ProgressBar/ProgressBar.test.js +89 -0
- package/dist/src/Select/Select.test.js +183 -0
- package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.js +51 -0
- package/dist/src/Select/components/SelectInternalPicker/SelectInternalPicker.test.js +72 -0
- package/dist/src/StatusLabel/StatusLabel.test.js +51 -0
- package/dist/src/Switch/Switch.test.js +60 -0
- package/dist/src/Switch/components/BaseSwitch/BaseSwitch.test.js +61 -0
- package/dist/src/Text/Text.test.js +161 -0
- package/dist/src/TextList/TextList.test.js +16 -0
- package/dist/src/ThumbnailList/ThumbnailList.test.js +72 -0
- package/dist/src/Toast/Toast.test.js +51 -0
- package/dist/src/Typography/Typography.test.js +225 -0
- package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.test.js +103 -0
- package/dist/src/utils/meta/meta.test.js +83 -0
- package/dist/tsconfig.build.json +5 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.eslint.json +14 -0
- package/dist/tsconfig.json +3 -4
- package/dist/types/src/ActionItem/ActionItem.test.d.ts +1 -0
- package/dist/types/src/ActionItem/ActionItemGroup.test.d.ts +1 -0
- package/dist/types/src/ActionItem/components/ActionItemContainer.test.d.ts +1 -0
- package/dist/types/src/ActionLabel/ActionLabel.test.d.ts +1 -0
- package/dist/types/src/ActivityIndicator/ActivityIndicator.test.d.ts +1 -0
- package/dist/types/src/AtlantisContext/AtlantisContext.test.d.ts +1 -0
- package/dist/types/src/AtlantisThemeContext/AtlantisThemeContext.test.d.ts +1 -0
- package/dist/types/src/AtlantisThemeContext/buildThemedStyles.test.d.ts +1 -0
- package/dist/types/src/AutoLink/AutoLink.test.d.ts +1 -0
- package/dist/types/src/AutoLink/components/Link/Link.test.d.ts +1 -0
- package/dist/types/src/Banner/Banner.test.d.ts +1 -0
- package/dist/types/src/BottomSheet/BottomSheet.test.d.ts +1 -0
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.test.d.ts +1 -0
- package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.test.d.ts +1 -0
- package/dist/types/src/Button/Button.test.d.ts +1 -0
- package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.test.d.ts +1 -0
- package/dist/types/src/ButtonGroup/ButtonGroup.test.d.ts +1 -0
- package/dist/types/src/Card/Card.test.d.ts +1 -0
- package/dist/types/src/Card/components/InternalCardHeader.test.d.ts +1 -0
- package/dist/types/src/Checkbox/Checkbox.test.d.ts +1 -0
- package/dist/types/src/Checkbox/CheckboxGroup.test.d.ts +1 -0
- package/dist/types/src/Checkbox/CheckboxGroupReducer.test.d.ts +1 -0
- package/dist/types/src/Chip/Chip.test.d.ts +1 -0
- package/dist/types/src/Content/Content.test.d.ts +1 -0
- package/dist/types/src/ContentOverlay/BottomSheetKeyboardAwareScrollView.d.ts +2 -1
- package/dist/types/src/ContentOverlay/ContentOverlay.test.d.ts +1 -0
- package/dist/types/src/ContentOverlay/computeContentOverlayBehavior.test.d.ts +1 -0
- package/dist/types/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.test.d.ts +1 -0
- package/dist/types/src/ContentOverlay/hooks/useKeyboardVisibility.test.d.ts +1 -0
- package/dist/types/src/ContentOverlay/hooks/useViewLayoutHeight.test.d.ts +1 -0
- package/dist/types/src/Disclosure/Disclosure.test.d.ts +1 -0
- package/dist/types/src/Divider/Divider.test.d.ts +1 -0
- package/dist/types/src/EmptyState/EmptyState.test.d.ts +1 -0
- package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.test.d.ts +1 -0
- package/dist/types/src/Flex/Flex.test.d.ts +1 -0
- package/dist/types/src/Form/Form.test.d.ts +1 -0
- package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.test.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessage/FormMessage.test.d.ts +1 -0
- package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.test.d.ts +1 -0
- package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.test.d.ts +1 -0
- package/dist/types/src/Form/context/AtlantisFormContext.test.d.ts +1 -0
- package/dist/types/src/Form/hooks/useScrollToError/useScrollToError.test.d.ts +1 -0
- package/dist/types/src/FormField/FormField.test.d.ts +1 -0
- package/dist/types/src/FormatFile/FormatFile.test.d.ts +1 -0
- package/dist/types/src/FormatFile/FormatFileThumbnail.test.d.ts +1 -0
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.d.ts +1 -0
- package/dist/types/src/FormatFile/components/MediaView/MediaView.test.d.ts +1 -0
- package/dist/types/src/FormatFile/utils/parseFile.test.d.ts +1 -0
- package/dist/types/src/Glimmer/Glimmer.test.d.ts +1 -0
- package/dist/types/src/Heading/Heading.test.d.ts +1 -0
- package/dist/types/src/Icon/Icon.test.d.ts +1 -0
- package/dist/types/src/IconButton/IconButton.test.d.ts +1 -0
- package/dist/types/src/InputCurrency/InputCurrency.test.d.ts +1 -0
- package/dist/types/src/InputDate/InputDate.test.d.ts +1 -0
- package/dist/types/src/InputEmail/InputEmail.test.d.ts +1 -0
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.test.d.ts +1 -0
- package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.test.d.ts +1 -0
- package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.test.d.ts +1 -0
- package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.test.d.ts +1 -0
- package/dist/types/src/InputNumber/InputNumber.test.d.ts +1 -0
- package/dist/types/src/InputPassword/InputPassword.test.d.ts +1 -0
- package/dist/types/src/InputPressable/InputPressable.test.d.ts +1 -0
- package/dist/types/src/InputSearch/InputSearch.test.d.ts +1 -0
- package/dist/types/src/InputText/InputText.test.d.ts +1 -0
- package/dist/types/src/InputText/context/InputAccessoriesProvider.test.d.ts +1 -0
- package/dist/types/src/InputTime/InputTime.test.d.ts +1 -0
- package/dist/types/src/InputTime/utils/utils.test.d.ts +1 -0
- package/dist/types/src/ProgressBar/ProgressBar.test.d.ts +1 -0
- package/dist/types/src/Select/Select.test.d.ts +1 -0
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.d.ts +1 -0
- package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.test.d.ts +1 -0
- package/dist/types/src/StatusLabel/StatusLabel.test.d.ts +1 -0
- package/dist/types/src/Switch/Switch.test.d.ts +1 -0
- package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.test.d.ts +1 -0
- package/dist/types/src/Text/Text.test.d.ts +1 -0
- package/dist/types/src/TextList/TextList.test.d.ts +1 -0
- package/dist/types/src/ThumbnailList/ThumbnailList.test.d.ts +1 -0
- package/dist/types/src/Toast/Toast.test.d.ts +1 -0
- package/dist/types/src/Typography/Typography.test.d.ts +1 -0
- package/dist/types/src/hooks/useAtlantisI18n/useAtlantisI18n.test.d.ts +1 -0
- package/dist/types/src/utils/meta/meta.test.d.ts +1 -0
- package/package.json +19 -11
- package/src/Button/Button.test.tsx +6 -2
- package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +3 -3
- package/src/Divider/Divider.stories.tsx +1 -1
- package/src/Flex/Flex.test.tsx +1 -1
- package/src/Form/Form.test.tsx +3 -1
- package/src/FormField/FormField.test.tsx +5 -1
- package/src/Heading/__snapshots__/Heading.test.tsx.snap +1 -1
- package/src/InputDate/InputDate.test.tsx +7 -1
- package/src/InputText/InputText.test.tsx +2 -1
- package/src/InputTime/InputTime.test.tsx +7 -1
- package/src/Select/Select.test.tsx +1 -1
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +8 -8
- package/src/Text/__snapshots__/Text.test.tsx.snap +2 -2
- package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +1 -1
- package/src/Typography/__snapshots__/Typography.test.tsx.snap +4 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { act, fireEvent, render as renderComponent, } from "@testing-library/react-native";
|
|
12
|
+
import { Animated } from "react-native";
|
|
13
|
+
import { GLIMMER_SHINE_TEST_ID, GLIMMER_TEST_ID, Glimmer } from "./Glimmer";
|
|
14
|
+
let screen;
|
|
15
|
+
function render(...params) {
|
|
16
|
+
screen = renderComponent(...params);
|
|
17
|
+
return screen;
|
|
18
|
+
}
|
|
19
|
+
describe("Glimmer", () => {
|
|
20
|
+
it("renders a Glimmer with default styling", () => {
|
|
21
|
+
render(React.createElement(Glimmer, null));
|
|
22
|
+
const element = screen.getByTestId(GLIMMER_TEST_ID);
|
|
23
|
+
expect(element.props.style).toEqual(expect.arrayContaining([
|
|
24
|
+
expect.objectContaining({ height: 16 }),
|
|
25
|
+
expect.objectContaining({ width: "100%" }),
|
|
26
|
+
]));
|
|
27
|
+
});
|
|
28
|
+
it("renders a Glimmer with custom width", () => {
|
|
29
|
+
render(React.createElement(Glimmer, { width: 50 }));
|
|
30
|
+
const element = screen.getByTestId(GLIMMER_TEST_ID);
|
|
31
|
+
expect(element.props.style).toEqual(expect.arrayContaining([expect.objectContaining({ width: 50 })]));
|
|
32
|
+
});
|
|
33
|
+
it("renders a Glimmer with custom percent width", () => {
|
|
34
|
+
render(React.createElement(Glimmer, { width: "50%" }));
|
|
35
|
+
const element = screen.getByTestId(GLIMMER_TEST_ID);
|
|
36
|
+
expect(element.props.style).toEqual(expect.arrayContaining([expect.objectContaining({ width: "50%" })]));
|
|
37
|
+
});
|
|
38
|
+
it("renders sets the correct width", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
jest.useFakeTimers();
|
|
40
|
+
// Spy on Animated.timing to verify the animation configuration
|
|
41
|
+
const timingSpy = jest.spyOn(Animated, "timing");
|
|
42
|
+
render(React.createElement(Glimmer, null));
|
|
43
|
+
yield act(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
fireEvent(screen.getByTestId(GLIMMER_TEST_ID), "onLayout", {
|
|
45
|
+
nativeEvent: { layout: { width: 300 } },
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
const element = screen.getByTestId(GLIMMER_SHINE_TEST_ID);
|
|
49
|
+
expect(element.props.style).toEqual(expect.objectContaining({ transform: [{ translateX: -48 }] }));
|
|
50
|
+
expect(timingSpy).toHaveBeenCalled();
|
|
51
|
+
// Get the last call to timing
|
|
52
|
+
const lastCall = timingSpy.mock.calls[timingSpy.mock.calls.length - 1];
|
|
53
|
+
// The first argument should be the animated value
|
|
54
|
+
// The second argument should be the config
|
|
55
|
+
const config = lastCall[1];
|
|
56
|
+
// Verify animation targets the right end position (300 + 48 = 348)
|
|
57
|
+
expect(config.toValue).toBe(348);
|
|
58
|
+
timingSpy.mockRestore();
|
|
59
|
+
jest.useRealTimers();
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
import { Heading } from "./Heading";
|
|
4
|
+
import { Text } from "../Text";
|
|
5
|
+
describe("when Heading called with text as the only prop", () => {
|
|
6
|
+
it("should match snapshot", () => {
|
|
7
|
+
const view = render(React.createElement(Heading, null, "Default Heading")).toJSON();
|
|
8
|
+
expect(view).toMatchSnapshot();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe("when Heading called with reverseTheme", () => {
|
|
12
|
+
it("should match snapshot", () => {
|
|
13
|
+
const view = render(React.createElement(Heading, { reverseTheme: true }, "Reverse Theme Heading")).toJSON();
|
|
14
|
+
expect(view).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe("when Heading called with title variation", () => {
|
|
18
|
+
it("should match snapshot", () => {
|
|
19
|
+
const view = render(React.createElement(Heading, { level: "title" }, "Title Heading")).toJSON();
|
|
20
|
+
expect(view).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe("when Heading called with Subtitle variation", () => {
|
|
24
|
+
it("should match snapshot", () => {
|
|
25
|
+
const view = render(React.createElement(Heading, { level: "subtitle" }, "Subtitle")).toJSON();
|
|
26
|
+
expect(view).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe("when Heading called with sub-heading variation", () => {
|
|
30
|
+
it("should match snapshot", () => {
|
|
31
|
+
const view = render(React.createElement(Heading, { level: "subHeading" }, "Sub-Heading")).toJSON();
|
|
32
|
+
expect(view).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe("when Heading called with sub-heading variation and text-color", () => {
|
|
36
|
+
it("should match snapshot", () => {
|
|
37
|
+
const view = render(React.createElement(Heading, { level: "subHeading", variation: "subdued" }, "Sub-Heading")).toJSON();
|
|
38
|
+
expect(view).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe("when Heading called with an alignment", () => {
|
|
42
|
+
it("should match snapshot", () => {
|
|
43
|
+
const view = render(React.createElement(Heading, { align: "end" }, "Text Aligned Right")).toJSON();
|
|
44
|
+
expect(view).toMatchSnapshot();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("when Heading called with maxLines", () => {
|
|
48
|
+
it("should match snapshot", () => {
|
|
49
|
+
const view = render(React.createElement(Heading, { maxLines: "single" }, "Text Aligned Right")).toJSON();
|
|
50
|
+
expect(view).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe("when Heading contains nested inline text", () => {
|
|
54
|
+
it("renders nested Text within Heading", () => {
|
|
55
|
+
const view = render(React.createElement(Heading, null,
|
|
56
|
+
"Heading before ",
|
|
57
|
+
React.createElement(Text, { emphasis: "strong" }, "Inner"),
|
|
58
|
+
" after")).toJSON();
|
|
59
|
+
expect(view).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
import { Icon } from ".";
|
|
4
|
+
it("renders home icon", () => {
|
|
5
|
+
const tree = render(React.createElement(Icon, { name: "home" })).toJSON();
|
|
6
|
+
expect(tree).toMatchSnapshot();
|
|
7
|
+
});
|
|
8
|
+
it("renders apple icon", () => {
|
|
9
|
+
const tree = render(React.createElement(Icon, { name: "apple" })).toJSON();
|
|
10
|
+
expect(tree).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
it("renders large arrowDown icon", () => {
|
|
13
|
+
const tree = render(React.createElement(Icon, { name: "arrowDown", size: "large" })).toJSON();
|
|
14
|
+
expect(tree).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
it("renders thumbsDown icon", () => {
|
|
17
|
+
const tree = render(React.createElement(Icon, { name: "thumbsDown" })).toJSON();
|
|
18
|
+
expect(tree).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
it("renders small more icon", () => {
|
|
21
|
+
const tree = render(React.createElement(Icon, { name: "more", size: "small" })).toJSON();
|
|
22
|
+
expect(tree).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
it("renders star icon with custom color", () => {
|
|
25
|
+
const tree = render(React.createElement(Icon, { name: "star", customColor: "#f33323" })).toJSON();
|
|
26
|
+
expect(tree).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
it("renders quote icon with themed color", () => {
|
|
29
|
+
// The intention is to make sure the color prop can be applied to an icon with a built-in default color
|
|
30
|
+
const tree = render(React.createElement(Icon, { name: "quote", color: "brand" })).toJSON();
|
|
31
|
+
expect(tree).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
it("applies testID prop to svg element", () => {
|
|
34
|
+
const { getByTestId } = render(React.createElement(Icon, { name: "home", testID: "home-icon" }));
|
|
35
|
+
expect(getByTestId("home-icon")).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
it("applies name prop as testID when testID prop is not provided", () => {
|
|
38
|
+
const { getByTestId } = render(React.createElement(Icon, { name: "home" }));
|
|
39
|
+
expect(getByTestId("home")).toBeDefined();
|
|
40
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { fireEvent, render } from "@testing-library/react-native";
|
|
3
|
+
import { IconButton } from "./IconButton";
|
|
4
|
+
import { Text } from "../Text";
|
|
5
|
+
describe("IconButton", () => {
|
|
6
|
+
it("renders an IconButton", () => {
|
|
7
|
+
const pressHandler = jest.fn();
|
|
8
|
+
const { getByTestId } = render(React.createElement(IconButton, { onPress: pressHandler, name: "job", accessibilityLabel: "Job Button", testID: "JobButton" }));
|
|
9
|
+
expect(getByTestId("JobButton")).toBeDefined();
|
|
10
|
+
});
|
|
11
|
+
it("should call the onPress", () => {
|
|
12
|
+
const pressHandler = jest.fn();
|
|
13
|
+
const { getByLabelText } = render(React.createElement(IconButton, { onPress: pressHandler, name: "job", accessibilityLabel: "Job Button" }));
|
|
14
|
+
fireEvent.press(getByLabelText("Job Button"));
|
|
15
|
+
expect(pressHandler).toHaveBeenCalled();
|
|
16
|
+
});
|
|
17
|
+
it("should render badge component", () => {
|
|
18
|
+
const pressHandler = jest.fn();
|
|
19
|
+
const badge = React.createElement(Text, null, "Hi");
|
|
20
|
+
const { getByText } = render(React.createElement(IconButton, { onPress: pressHandler, name: "job", badge: badge, accessibilityLabel: "Job Button" }));
|
|
21
|
+
expect(getByText("Hi")).toBeDefined();
|
|
22
|
+
});
|
|
23
|
+
it("should render IconButton with custom color", () => {
|
|
24
|
+
const pressHandler = jest.fn();
|
|
25
|
+
const { getByLabelText } = render(React.createElement(IconButton, { onPress: pressHandler, name: "job", customColor: "#f33323", accessibilityLabel: "Job Button" }));
|
|
26
|
+
const iconBtnColorProp = getByLabelText("Job Button").findByProps({
|
|
27
|
+
customColor: "#f33323",
|
|
28
|
+
}).props.customColor;
|
|
29
|
+
expect(iconBtnColorProp).toEqual("#f33323");
|
|
30
|
+
});
|
|
31
|
+
it("should expose testID", () => {
|
|
32
|
+
const pressHandler = jest.fn();
|
|
33
|
+
const testID = "JobButton";
|
|
34
|
+
const { getByTestId } = render(React.createElement(IconButton, { onPress: pressHandler, name: "job", accessibilityLabel: "Job Button", testID: testID }));
|
|
35
|
+
fireEvent.press(getByTestId(testID));
|
|
36
|
+
expect(pressHandler).toHaveBeenCalled();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
12
|
+
import { InputCurrency } from "./InputCurrency";
|
|
13
|
+
import { AtlantisContext, atlantisContextDefaultValues, } from "../AtlantisContext";
|
|
14
|
+
const mockCurrencySymbol = "£";
|
|
15
|
+
const atlantisContext = Object.assign(Object.assign({}, atlantisContextDefaultValues), { currencySymbol: mockCurrencySymbol, timeFormat: "p", timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone, isOnline: true, onLogError: err => {
|
|
16
|
+
return err;
|
|
17
|
+
}, floatSeparators: { group: ",", decimal: "." } });
|
|
18
|
+
const placeHolder = "Price";
|
|
19
|
+
describe.each([{ includeATLContext: true }, { includeATLContext: false }])("Has AtlantisContext: $includeATLContext", ({ includeATLContext }) => {
|
|
20
|
+
function setup({ showCurrencySymbol, name, }) {
|
|
21
|
+
if (includeATLContext) {
|
|
22
|
+
return render(React.createElement(AtlantisContext.Provider, { value: atlantisContext },
|
|
23
|
+
React.createElement(InputCurrency, { placeholder: placeHolder, name: name, showCurrencySymbol: showCurrencySymbol })));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return render(React.createElement(InputCurrency, { placeholder: placeHolder, name: name, showCurrencySymbol: showCurrencySymbol }));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
it("renders with currency symbol when the value is input", () => {
|
|
30
|
+
const { getByText, getByLabelText } = setup({
|
|
31
|
+
name: "sample",
|
|
32
|
+
});
|
|
33
|
+
const value = 123.459119;
|
|
34
|
+
const expectedCurrencySymbol = includeATLContext
|
|
35
|
+
? mockCurrencySymbol
|
|
36
|
+
: "$";
|
|
37
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
38
|
+
expect(getByText(expectedCurrencySymbol)).toBeDefined();
|
|
39
|
+
});
|
|
40
|
+
it("renders without currency symbol", () => {
|
|
41
|
+
const { queryByText, getByLabelText } = setup({
|
|
42
|
+
name: "sample",
|
|
43
|
+
showCurrencySymbol: false,
|
|
44
|
+
});
|
|
45
|
+
const value = 123.459119;
|
|
46
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
47
|
+
expect(queryByText(mockCurrencySymbol)).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
it("displays a maximum 5 decimal places", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const value = 123.459119;
|
|
51
|
+
const { getByLabelText, getByDisplayValue } = setup({
|
|
52
|
+
name: "sample",
|
|
53
|
+
});
|
|
54
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
55
|
+
yield waitFor(() => {
|
|
56
|
+
expect(getByDisplayValue("123.45912")).toBeDefined();
|
|
57
|
+
});
|
|
58
|
+
}));
|
|
59
|
+
it("displays a minimum of 2 decimal places", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const value = 123.11;
|
|
61
|
+
const { getByLabelText, getByDisplayValue } = setup({ name: "sample" });
|
|
62
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
63
|
+
yield waitFor(() => {
|
|
64
|
+
expect(getByDisplayValue("123.11")).toBeDefined();
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
it("displays a negative value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
const value = -509.543;
|
|
69
|
+
const { getByLabelText, getByDisplayValue } = setup({ name: "sample" });
|
|
70
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
71
|
+
yield waitFor(() => {
|
|
72
|
+
expect(getByDisplayValue(`${value}`)).toBeDefined();
|
|
73
|
+
});
|
|
74
|
+
}));
|
|
75
|
+
it("internationalizes the display Value in the input", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const value = 5098.543;
|
|
77
|
+
const { getByLabelText, getByDisplayValue } = setup({ name: "sample" });
|
|
78
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
79
|
+
yield waitFor(() => {
|
|
80
|
+
expect(getByDisplayValue("5,098.543")).toBeDefined();
|
|
81
|
+
});
|
|
82
|
+
}));
|
|
83
|
+
it("limits the whole number integer to 10 whole integers by default", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const value = 12345678998;
|
|
85
|
+
const { getByLabelText, getByDisplayValue } = setup({ name: "sample" });
|
|
86
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
87
|
+
yield waitFor(() => {
|
|
88
|
+
expect(getByDisplayValue("1,234,567,899")).toBeDefined();
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
91
|
+
it("rounds the decimal point if there are more decimal numbers than the maxDecimalCount", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
const value = 123456.789988;
|
|
93
|
+
const { getByLabelText, getByDisplayValue } = setup({ name: "sample" });
|
|
94
|
+
fireEvent.changeText(getByLabelText(placeHolder), `${value}`);
|
|
95
|
+
yield waitFor(() => {
|
|
96
|
+
expect(getByDisplayValue("123,456.78999")).toBeDefined();
|
|
97
|
+
});
|
|
98
|
+
}));
|
|
99
|
+
it("displays 0 on blur if there is no inputted value or the field.value is undefined", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const { getByLabelText, getByDisplayValue } = setup({ name: "sample" });
|
|
101
|
+
fireEvent(getByLabelText("Price"), "blur");
|
|
102
|
+
yield waitFor(() => {
|
|
103
|
+
expect(getByDisplayValue("0")).toBeDefined();
|
|
104
|
+
});
|
|
105
|
+
}));
|
|
106
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
12
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
13
|
+
import { Keyboard } from "react-native";
|
|
14
|
+
import { InputDate } from "./InputDate";
|
|
15
|
+
import { Button } from "../Button";
|
|
16
|
+
import * as atlantisContext from "../AtlantisContext/AtlantisContext";
|
|
17
|
+
const keyboardDismissSpy = jest.spyOn(Keyboard, "dismiss");
|
|
18
|
+
describe("InputDate", () => {
|
|
19
|
+
describe("Visuals", () => {
|
|
20
|
+
const placeholder = "Start time";
|
|
21
|
+
const expectedDate = "May 30, 2022";
|
|
22
|
+
const value = new Date(2022, 4, 30);
|
|
23
|
+
const handleChange = jest.fn();
|
|
24
|
+
const setup = () => render(React.createElement(InputDate, { placeholder: placeholder, value: value, onChange: handleChange }));
|
|
25
|
+
it("should show a calendar prefix icon", () => {
|
|
26
|
+
const screen = setup();
|
|
27
|
+
const calendarIcon = screen.getByTestId("calendar");
|
|
28
|
+
expect(calendarIcon).toBeDefined();
|
|
29
|
+
expect(calendarIcon.type).toBe("RNSVGSvgView");
|
|
30
|
+
});
|
|
31
|
+
it("should show a formatted date", () => {
|
|
32
|
+
const screen = setup();
|
|
33
|
+
expect(screen.getByText(expectedDate, { includeHiddenElements: true })).toBeDefined();
|
|
34
|
+
});
|
|
35
|
+
it("should be clearable when there's a value", () => {
|
|
36
|
+
const screen = setup();
|
|
37
|
+
const clearAction = screen.getByLabelText("Clear input");
|
|
38
|
+
expect(clearAction).toBeDefined();
|
|
39
|
+
fireEvent.press(clearAction);
|
|
40
|
+
expect(handleChange).toHaveBeenCalledWith(undefined);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe("String value", () => {
|
|
44
|
+
it("should show a formatted date", () => {
|
|
45
|
+
const expectedDate = "May 31, 2022";
|
|
46
|
+
const value = new Date(2022, 4, 31).toISOString();
|
|
47
|
+
const screen = render(React.createElement(InputDate, { value: value, onChange: jest.fn() }));
|
|
48
|
+
expect(screen.getByText(expectedDate, { includeHiddenElements: true })).toBeDefined();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe("With emptyValueLabel", () => {
|
|
52
|
+
it("should show the emptyValueLabel when there's no value", () => {
|
|
53
|
+
const label = "Unscheduled";
|
|
54
|
+
const screen = render(React.createElement(InputDate, { name: "test", emptyValueLabel: label }));
|
|
55
|
+
expect(screen.getByText(label, { includeHiddenElements: true })).toBeDefined();
|
|
56
|
+
expect(screen.queryByLabelText("Clear input")).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
it("should not show the emptyValueLabel when there's a value", () => {
|
|
59
|
+
const label = "Unscheduled";
|
|
60
|
+
const screen = render(React.createElement(InputDate, { emptyValueLabel: label, value: new Date(), onChange: jest.fn() }));
|
|
61
|
+
expect(screen.queryByText(label)).toBeNull();
|
|
62
|
+
expect(screen.getByLabelText("Clear input")).toBeDefined();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe("with a defaultValue", () => {
|
|
66
|
+
it("renders the supplied value", () => {
|
|
67
|
+
const { getByText } = render(React.createElement(InputDate, { name: "test", defaultValue: new Date("2022-01-17") }));
|
|
68
|
+
expect(getByText("Jan 17, 2022", { includeHiddenElements: true })).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("Date picker", () => {
|
|
72
|
+
const placeholder = "Tap me";
|
|
73
|
+
const handleChange = jest.fn();
|
|
74
|
+
function renderDatePicker() {
|
|
75
|
+
const screen = render(React.createElement(InputDate, { placeholder: placeholder, value: undefined, onChange: handleChange }));
|
|
76
|
+
fireEvent.press(screen.getByLabelText(placeholder));
|
|
77
|
+
expect(screen.getByTestId("inputDate-datePicker")).toBeDefined();
|
|
78
|
+
return screen;
|
|
79
|
+
}
|
|
80
|
+
it("should not show a date picker", () => {
|
|
81
|
+
const screen = render(React.createElement(InputDate, { name: "test" }));
|
|
82
|
+
expect(screen.queryByTestId("inputDate-datePicker")).toBeNull();
|
|
83
|
+
});
|
|
84
|
+
it("should fire the onChange with the current value after canceling a date selection", () => {
|
|
85
|
+
const screen = renderDatePicker();
|
|
86
|
+
fireEvent.press(screen.getByLabelText("Cancel"));
|
|
87
|
+
expect(handleChange).toHaveBeenCalledWith(undefined);
|
|
88
|
+
});
|
|
89
|
+
it("should fire the onChange after confirming a date selection", () => {
|
|
90
|
+
const screen = renderDatePicker();
|
|
91
|
+
fireEvent.press(screen.getByLabelText("Confirm"));
|
|
92
|
+
expect(handleChange).toHaveBeenCalledWith(expect.any(Date));
|
|
93
|
+
});
|
|
94
|
+
it("should dismiss the keyboard when the date picker is opened", () => {
|
|
95
|
+
renderDatePicker();
|
|
96
|
+
expect(keyboardDismissSpy).toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
const mockOnSubmit = jest.fn();
|
|
100
|
+
const saveButtonText = "Submit";
|
|
101
|
+
const requiredError = "This is required";
|
|
102
|
+
function SimpleFormWithProvider({ children, defaultValues, }) {
|
|
103
|
+
const formMethods = useForm({
|
|
104
|
+
reValidateMode: "onChange",
|
|
105
|
+
defaultValues,
|
|
106
|
+
mode: "onTouched",
|
|
107
|
+
});
|
|
108
|
+
return (React.createElement(FormProvider, Object.assign({}, formMethods),
|
|
109
|
+
children,
|
|
110
|
+
React.createElement(Button, { onPress: formMethods.handleSubmit(values => mockOnSubmit(values)), label: saveButtonText, accessibilityLabel: saveButtonText })));
|
|
111
|
+
}
|
|
112
|
+
describe("Form controlled", () => {
|
|
113
|
+
const pickerName = "datePicker";
|
|
114
|
+
const expectedDate = "May 29, 2022";
|
|
115
|
+
const value = new Date(2022, 4, 29);
|
|
116
|
+
const handleChange = jest.fn();
|
|
117
|
+
const setup = () => render(React.createElement(SimpleFormWithProvider, { defaultValues: { [pickerName]: value } },
|
|
118
|
+
React.createElement(InputDate, { name: pickerName, onChange: handleChange, validations: { required: requiredError } })));
|
|
119
|
+
it("should show the initial value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
const screen = setup();
|
|
121
|
+
expect(screen.getByText(expectedDate, {
|
|
122
|
+
includeHiddenElements: true,
|
|
123
|
+
})).toBeDefined();
|
|
124
|
+
}));
|
|
125
|
+
it("should update the value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
const screen = yield setup();
|
|
127
|
+
fireEvent.press(screen.getByText(expectedDate, { includeHiddenElements: true }));
|
|
128
|
+
const expectedNewDate = "Jun 17, 2022";
|
|
129
|
+
const newSelectedDate = new Date(2022, 5, 17);
|
|
130
|
+
fireEvent(screen.getByTestId("inputDate-datePicker"), "onConfirm", newSelectedDate);
|
|
131
|
+
expect(screen.getByText(expectedNewDate, { includeHiddenElements: true })).toBeDefined();
|
|
132
|
+
expect(handleChange).toHaveBeenCalledWith(newSelectedDate);
|
|
133
|
+
}));
|
|
134
|
+
it("should show the client side validation error", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
135
|
+
const screen = setup();
|
|
136
|
+
const clearAction = screen.getByLabelText("Clear input");
|
|
137
|
+
expect(clearAction).toBeDefined();
|
|
138
|
+
fireEvent.press(clearAction);
|
|
139
|
+
yield waitFor(() => {
|
|
140
|
+
expect(screen.getAllByText(requiredError, { includeHiddenElements: true })).toHaveLength(1);
|
|
141
|
+
});
|
|
142
|
+
}));
|
|
143
|
+
it("should clear the input with null value when it is in a form", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
|
+
const screen = setup();
|
|
145
|
+
const clearAction = screen.getByLabelText("Clear input");
|
|
146
|
+
expect(clearAction).toBeDefined();
|
|
147
|
+
fireEvent.press(clearAction);
|
|
148
|
+
expect(handleChange).toHaveBeenCalledWith(null);
|
|
149
|
+
}));
|
|
150
|
+
});
|
|
151
|
+
describe("dateFormat pattern", () => {
|
|
152
|
+
afterEach(() => {
|
|
153
|
+
jest.spyOn(atlantisContext, "useAtlantisContext").mockRestore();
|
|
154
|
+
});
|
|
155
|
+
it("should display MM/DD/YYYY when dateFormat is 'P'", () => {
|
|
156
|
+
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue(Object.assign(Object.assign({}, atlantisContext.atlantisContextDefaultValues), { dateFormat: "P" }));
|
|
157
|
+
const expectedDate = "05/24/2023";
|
|
158
|
+
const value = new Date(2023, 4, 24).toISOString();
|
|
159
|
+
const screen = render(React.createElement(InputDate, { value: value, onChange: jest.fn() }));
|
|
160
|
+
expect(screen.getByText(expectedDate, { includeHiddenElements: true })).toBeDefined();
|
|
161
|
+
});
|
|
162
|
+
it("should display mmmm d, yyyy when dateFormat is 'PP'", () => {
|
|
163
|
+
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue(Object.assign(Object.assign({}, atlantisContext.atlantisContextDefaultValues), { dateFormat: "PP" }));
|
|
164
|
+
const expectedDate = "Feb 20, 2023";
|
|
165
|
+
const value = new Date(2023, 1, 20).toISOString();
|
|
166
|
+
const screen = render(React.createElement(InputDate, { value: value, onChange: jest.fn() }));
|
|
167
|
+
expect(screen.getByText(expectedDate, { includeHiddenElements: true })).toBeDefined();
|
|
168
|
+
});
|
|
169
|
+
it("should display mmmmm d, yyyy when dateFormat is 'PPP'", () => {
|
|
170
|
+
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue(Object.assign(Object.assign({}, atlantisContext.atlantisContextDefaultValues), { dateFormat: "PPP" }));
|
|
171
|
+
const expectedDate = "July 7th, 2023";
|
|
172
|
+
const value = new Date(2023, 6, 7).toISOString();
|
|
173
|
+
const screen = render(React.createElement(InputDate, { value: value, onChange: jest.fn() }));
|
|
174
|
+
expect(screen.getByText(expectedDate, { includeHiddenElements: true })).toBeDefined();
|
|
175
|
+
});
|
|
176
|
+
it("should display dddd, mmmmm d, yyyy when dateFormat is 'PPPP'", () => {
|
|
177
|
+
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue(Object.assign(Object.assign({}, atlantisContext.atlantisContextDefaultValues), { dateFormat: "PPPP" }));
|
|
178
|
+
const expectedDate = "Thursday, June 22nd, 2023";
|
|
179
|
+
const value = new Date(2023, 5, 22).toISOString();
|
|
180
|
+
const screen = render(React.createElement(InputDate, { value: value, onChange: jest.fn() }));
|
|
181
|
+
expect(screen.getByText(expectedDate, { includeHiddenElements: true })).toBeDefined();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
12
|
+
import { InputEmail } from ".";
|
|
13
|
+
it("renders an InputEmail", () => {
|
|
14
|
+
const value = "test@test.com";
|
|
15
|
+
const { getByDisplayValue } = render(React.createElement(InputEmail, { value: value }));
|
|
16
|
+
expect(getByDisplayValue(value)).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
it("displays the validtion message when an invalid email is entered", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const a11yLabel = "InputEmailTest";
|
|
20
|
+
const { getByText, getByLabelText } = render(React.createElement(InputEmail, { value: "notanemail", accessibilityLabel: a11yLabel }));
|
|
21
|
+
yield waitFor(() => {
|
|
22
|
+
fireEvent(getByLabelText(a11yLabel), "blur");
|
|
23
|
+
});
|
|
24
|
+
expect(getByText("Enter a valid email address (email@example.com)", {
|
|
25
|
+
includeHiddenElements: true,
|
|
26
|
+
})).toBeDefined();
|
|
27
|
+
}));
|