@onewelcome/react-lib-components 0.2.0 → 0.2.3
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/Breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/Button/BaseButton.d.ts +4 -4
- package/dist/Button/Button.d.ts +3 -3
- package/dist/Button/IconButton.d.ts +4 -4
- package/dist/ContextMenu/ContextMenu.d.ts +5 -5
- package/dist/ContextMenu/ContextMenuItem.d.ts +2 -2
- package/dist/DataGrid/DataGrid.d.ts +6 -6
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +4 -4
- package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +3 -3
- package/dist/DataGrid/DataGridBody/DataGridBody.d.ts +3 -3
- package/dist/DataGrid/DataGridBody/DataGridCell.d.ts +2 -2
- package/dist/DataGrid/DataGridBody/DataGridRow.d.ts +3 -3
- package/dist/DataGrid/DataGridHeader/DataGridHeader.d.ts +3 -3
- package/dist/DataGrid/DataGridHeader/DataGridHeaderCell.d.ts +3 -3
- package/dist/DataGrid/datagrid.interfaces.d.ts +1 -1
- package/dist/Form/Checkbox/Checkbox.d.ts +5 -5
- package/dist/Form/Fieldset/Fieldset.d.ts +3 -3
- package/dist/Form/Form.d.ts +1 -1
- package/dist/Form/FormControl/FormControl.d.ts +3 -3
- package/dist/Form/FormGroup/FormGroup.d.ts +5 -5
- package/dist/Form/FormHelperText/FormHelperText.d.ts +3 -3
- package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +6 -6
- package/dist/Form/Input/Input.d.ts +5 -5
- package/dist/Form/Label/Label.d.ts +2 -2
- package/dist/Form/Radio/Radio.d.ts +5 -5
- package/dist/Form/Select/Option.d.ts +2 -2
- package/dist/Form/Select/Select.d.ts +5 -5
- package/dist/Form/Textarea/Textarea.d.ts +6 -6
- package/dist/Form/Toggle/Toggle.d.ts +3 -3
- package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/Wrapper/Wrapper.d.ts +6 -6
- package/dist/Form/form.interfaces.d.ts +1 -1
- package/dist/Icon/Icon.d.ts +3 -3
- package/dist/Link/Link.d.ts +7 -7
- package/dist/Notifications/BaseModal/BaseModal.d.ts +4 -4
- package/dist/Notifications/BaseModal/BaseModalActions/BaseModalActions.d.ts +2 -2
- package/dist/Notifications/BaseModal/BaseModalContent/BaseModalContent.d.ts +2 -2
- package/dist/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +2 -2
- package/dist/Notifications/Dialog/Dialog.d.ts +5 -5
- package/dist/Notifications/Dialog/DialogActions/DialogActions.d.ts +3 -3
- package/dist/Notifications/Dialog/DialogTitle/DialogTitle.d.ts +2 -2
- package/dist/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.d.ts +3 -3
- package/dist/Notifications/DiscardChangesModal/DiscardChangesModal.d.ts +7 -7
- package/dist/Notifications/Modal/Modal.d.ts +1 -1
- package/dist/Notifications/Modal/ModalActions/ModalActions.d.ts +1 -1
- package/dist/Notifications/Modal/ModalContent/ModalContent.d.ts +1 -1
- package/dist/Notifications/Modal/ModalHeader/ModalHeader.d.ts +1 -1
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarItem/SnackbarItem.d.ts +2 -2
- package/dist/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +2 -2
- package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
- package/dist/Pagination/Pagination.d.ts +3 -3
- package/dist/Popover/Popover.d.ts +3 -3
- package/dist/Skeleton/Skeleton.d.ts +3 -3
- package/dist/StatusIndicator/StatusIndicator.d.ts +5 -5
- package/dist/Tabs/Tab.d.ts +1 -1
- package/dist/Tabs/TabButton.d.ts +2 -2
- package/dist/Tabs/TabPanel.d.ts +2 -2
- package/dist/Tabs/Tabs.d.ts +4 -4
- package/dist/TextEllipsis/TextEllipsis.d.ts +2 -2
- package/dist/Tiles/Tile.d.ts +5 -5
- package/dist/Tiles/Tiles.d.ts +2 -2
- package/dist/Tooltip/Tooltip.d.ts +3 -3
- package/dist/Typography/Typography.d.ts +3 -3
- package/dist/Wizard/BaseWizardSteps/BaseWizardSteps.d.ts +2 -2
- package/dist/Wizard/Wizard.d.ts +3 -3
- package/dist/Wizard/WizardActions/WizardActions.d.ts +2 -2
- package/dist/Wizard/WizardStateProvider.d.ts +2 -2
- package/dist/Wizard/WizardSteps/WizardSteps.d.ts +2 -2
- package/dist/Wizard/wizardStateReducer.d.ts +5 -5
- package/dist/_BaseStyling_/BaseStyling.d.ts +1 -1
- package/dist/hooks/usePosition.d.ts +4 -4
- package/dist/hooks/useRepeater.d.ts +1 -1
- package/dist/hooks/useScroll.d.ts +1 -1
- package/dist/hooks/useSpacing.d.ts +1 -1
- package/dist/hooks/useWrapper.d.ts +1 -1
- package/dist/index.d.ts +55 -55
- package/dist/react-lib-components.cjs.development.js +676 -578
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +676 -578
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +27 -16
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +15 -15
- package/src/Breadcrumbs/Breadcrumbs.tsx +11 -11
- package/src/Button/BaseButton.module.scss +1 -1
- package/src/Button/BaseButton.test.tsx +27 -27
- package/src/Button/BaseButton.tsx +8 -8
- package/src/Button/Button.module.scss +5 -5
- package/src/Button/Button.test.tsx +39 -39
- package/src/Button/Button.tsx +10 -10
- package/src/Button/IconButton.module.scss +5 -5
- package/src/Button/IconButton.test.tsx +29 -29
- package/src/Button/IconButton.tsx +11 -11
- package/src/ContextMenu/ContextMenu.test.tsx +97 -76
- package/src/ContextMenu/ContextMenu.tsx +48 -42
- package/src/ContextMenu/ContextMenuItem.module.scss +1 -1
- package/src/ContextMenu/ContextMenuItem.tsx +7 -5
- package/src/DataGrid/DataGrid.test.tsx +193 -193
- package/src/DataGrid/DataGrid.tsx +26 -26
- package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +63 -63
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +15 -15
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss +1 -1
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.test.tsx +21 -21
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +20 -20
- package/src/DataGrid/DataGridBody/DataGridBody.test.tsx +40 -40
- package/src/DataGrid/DataGridBody/DataGridBody.tsx +10 -10
- package/src/DataGrid/DataGridBody/DataGridCell.module.scss +1 -1
- package/src/DataGrid/DataGridBody/DataGridCell.test.tsx +25 -25
- package/src/DataGrid/DataGridBody/DataGridCell.tsx +6 -6
- package/src/DataGrid/DataGridBody/DataGridRow.test.tsx +38 -38
- package/src/DataGrid/DataGridBody/DataGridRow.tsx +8 -8
- package/src/DataGrid/DataGridHeader/DataGridHeader.module.scss +1 -2
- package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +119 -119
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +13 -13
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +2 -0
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.test.tsx +51 -51
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +14 -14
- package/src/DataGrid/datagrid.interfaces.ts +1 -1
- package/src/Form/Checkbox/Checkbox.test.tsx +74 -74
- package/src/Form/Checkbox/Checkbox.tsx +27 -27
- package/src/Form/Fieldset/Fieldset.module.scss +1 -1
- package/src/Form/Fieldset/Fieldset.test.tsx +35 -35
- package/src/Form/Fieldset/Fieldset.tsx +27 -27
- package/src/Form/Form.test.tsx +18 -18
- package/src/Form/Form.tsx +3 -3
- package/src/Form/FormControl/FormControl.test.tsx +22 -22
- package/src/Form/FormControl/FormControl.tsx +10 -10
- package/src/Form/FormGroup/FormGroup.test.tsx +37 -37
- package/src/Form/FormGroup/FormGroup.tsx +16 -16
- package/src/Form/FormHelperText/FormHelperText.test.tsx +18 -18
- package/src/Form/FormHelperText/FormHelperText.tsx +7 -7
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +15 -15
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +14 -14
- package/src/Form/Input/Input.module.scss +20 -44
- package/src/Form/Input/Input.test.tsx +121 -73
- package/src/Form/Input/Input.tsx +96 -35
- package/src/Form/Label/Label.test.tsx +13 -13
- package/src/Form/Label/Label.tsx +6 -6
- package/src/Form/Radio/Radio.test.tsx +35 -35
- package/src/Form/Radio/Radio.tsx +17 -17
- package/src/Form/Select/Option.test.tsx +10 -10
- package/src/Form/Select/Option.tsx +8 -8
- package/src/Form/Select/Select.module.scss +7 -9
- package/src/Form/Select/Select.test.tsx +144 -141
- package/src/Form/Select/Select.tsx +79 -78
- package/src/Form/Textarea/Textarea.module.scss +8 -18
- package/src/Form/Textarea/Textarea.test.tsx +27 -27
- package/src/Form/Textarea/Textarea.tsx +33 -13
- package/src/Form/Toggle/Toggle.module.scss +1 -1
- package/src/Form/Toggle/Toggle.test.tsx +22 -22
- package/src/Form/Toggle/Toggle.tsx +10 -10
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +39 -39
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +12 -12
- package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +2 -8
- package/src/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +55 -55
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +30 -35
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +35 -35
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +12 -12
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +55 -55
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -12
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +2 -11
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +50 -50
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +22 -22
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
- package/src/Form/Wrapper/Wrapper/Wrapper.test.tsx +11 -11
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +17 -17
- package/src/Form/form.interfaces.ts +1 -1
- package/src/Icon/Icon.module.scss +71 -71
- package/src/Icon/Icon.test.tsx +18 -18
- package/src/Icon/Icon.tsx +70 -70
- package/src/Link/Link.module.scss +5 -5
- package/src/Link/Link.test.tsx +76 -76
- package/src/Link/Link.tsx +27 -27
- package/src/Link/types.d.ts +1 -1
- package/src/Notifications/BaseModal/BaseModal.module.scss +1 -1
- package/src/Notifications/BaseModal/BaseModal.test.tsx +53 -53
- package/src/Notifications/BaseModal/BaseModal.tsx +16 -16
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +13 -13
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +5 -5
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.test.tsx +16 -16
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +5 -5
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.test.tsx +19 -19
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +10 -10
- package/src/Notifications/Dialog/Dialog.test.tsx +35 -35
- package/src/Notifications/Dialog/Dialog.tsx +19 -19
- package/src/Notifications/Dialog/DialogActions/DialogActions.test.tsx +14 -14
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +6 -6
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +12 -12
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +6 -6
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +20 -20
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +7 -7
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +36 -36
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.tsx +8 -8
- package/src/Notifications/Modal/Modal.test.tsx +6 -6
- package/src/Notifications/Modal/Modal.tsx +1 -1
- package/src/Notifications/Modal/ModalActions/ModalActions.tsx +2 -2
- package/src/Notifications/Modal/ModalContent/ModalContent.tsx +2 -2
- package/src/Notifications/Modal/ModalHeader/ModalHeader.tsx +2 -2
- package/src/Notifications/SlideInModal/SlideInModal.test.tsx +16 -16
- package/src/Notifications/SlideInModal/SlideInModal.tsx +16 -11
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.test.tsx +16 -16
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.tsx +6 -6
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +2 -2
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.test.tsx +17 -17
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +23 -23
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +32 -32
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.tsx +18 -18
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +3 -3
- package/src/Notifications/Snackbar/interfaces.ts +2 -2
- package/src/Notifications/Snackbar/useSnackbar.ts +2 -2
- package/src/Pagination/Pagination.module.scss +2 -0
- package/src/Pagination/Pagination.test.tsx +47 -47
- package/src/Pagination/Pagination.tsx +35 -35
- package/src/Popover/Popover.test.tsx +19 -19
- package/src/Popover/Popover.tsx +7 -7
- package/src/Skeleton/Skeleton.module.scss +2 -2
- package/src/Skeleton/Skeleton.test.tsx +29 -29
- package/src/Skeleton/Skeleton.tsx +10 -10
- package/src/StatusIndicator/StatusIndicator.test.tsx +38 -38
- package/src/StatusIndicator/StatusIndicator.tsx +9 -9
- package/src/Tabs/Tab.test.tsx +13 -13
- package/src/Tabs/Tab.tsx +1 -1
- package/src/Tabs/TabButton.test.tsx +28 -28
- package/src/Tabs/TabButton.tsx +7 -7
- package/src/Tabs/TabPanel.test.tsx +30 -30
- package/src/Tabs/TabPanel.tsx +4 -4
- package/src/Tabs/Tabs.test.tsx +93 -93
- package/src/Tabs/Tabs.tsx +25 -25
- package/src/TextEllipsis/TextEllipsis.test.tsx +22 -22
- package/src/TextEllipsis/TextEllipsis.tsx +6 -6
- package/src/Tiles/Tile.module.scss +1 -1
- package/src/Tiles/Tile.test.tsx +42 -42
- package/src/Tiles/Tile.tsx +22 -22
- package/src/Tiles/Tiles.test.tsx +30 -30
- package/src/Tiles/Tiles.tsx +9 -9
- package/src/Tooltip/Tooltip.test.tsx +35 -35
- package/src/Tooltip/Tooltip.tsx +21 -21
- package/src/Typography/Typography.module.scss +1 -1
- package/src/Typography/Typography.test.tsx +49 -49
- package/src/Typography/Typography.tsx +42 -42
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.module.scss +1 -1
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.test.tsx +26 -26
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +24 -24
- package/src/Wizard/Wizard.test.tsx +56 -56
- package/src/Wizard/Wizard.tsx +6 -6
- package/src/Wizard/WizardActions/WizardActions.test.tsx +34 -34
- package/src/Wizard/WizardActions/WizardActions.tsx +14 -14
- package/src/Wizard/WizardStateProvider.tsx +3 -3
- package/src/Wizard/WizardSteps/WizardSteps.test.tsx +27 -27
- package/src/Wizard/WizardSteps/WizardSteps.tsx +7 -7
- package/src/Wizard/wizardStateReducer.ts +9 -9
- package/src/_BaseStyling_/BaseStyling.test.tsx +14 -14
- package/src/_BaseStyling_/BaseStyling.tsx +50 -50
- package/src/hooks/useAnimation.test.tsx +12 -12
- package/src/hooks/useAnimation.ts +4 -4
- package/src/hooks/useBodyClick.test.tsx +8 -8
- package/src/hooks/useBodyClick.ts +3 -3
- package/src/hooks/useFormSelector.test.ts +17 -17
- package/src/hooks/useFormSelector.ts +4 -4
- package/src/hooks/usePosition.test.tsx +215 -215
- package/src/hooks/usePosition.ts +68 -68
- package/src/hooks/useRepeater.test.tsx +26 -26
- package/src/hooks/useRepeater.ts +5 -5
- package/src/hooks/useScroll.test.tsx +5 -5
- package/src/hooks/useScroll.ts +3 -3
- package/src/hooks/useSpacing.test.ts +40 -40
- package/src/hooks/useSpacing.ts +3 -3
- package/src/hooks/useWrapper.test.ts +12 -12
- package/src/hooks/useWrapper.ts +14 -7
- package/src/index.ts +67 -67
- package/src/mixins.module.scss +76 -27
- package/src/types.d.ts +1 -1
- package/src/util/helper.test.tsx +25 -25
- package/src/util/helper.tsx +64 -64
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { Fieldset, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { FormControl } from
|
|
5
|
-
import { Input } from
|
|
6
|
-
import { Select } from
|
|
7
|
-
import { Option } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Fieldset, Props } from "./Fieldset";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { FormControl } from "../FormControl/FormControl";
|
|
5
|
+
import { Input } from "../Input/Input";
|
|
6
|
+
import { Select } from "../Select/Select";
|
|
7
|
+
import { Option } from "../Select/Option";
|
|
8
8
|
|
|
9
9
|
const defaultParams: Props = {
|
|
10
|
-
legend:
|
|
11
|
-
legendStyle:
|
|
10
|
+
legend: "Example",
|
|
11
|
+
legendStyle: "h2",
|
|
12
12
|
children: [
|
|
13
13
|
<FormControl data-testid="form-control">
|
|
14
14
|
<Input placeholder="This is a placeholder" name="example" type="text" />
|
|
@@ -19,8 +19,8 @@ const defaultParams: Props = {
|
|
|
19
19
|
<Option value="option2">Option2</Option>
|
|
20
20
|
<Option value="option3">Option3</Option>
|
|
21
21
|
</Select>
|
|
22
|
-
</FormControl
|
|
23
|
-
]
|
|
22
|
+
</FormControl>
|
|
23
|
+
]
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const createFieldset = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -29,26 +29,26 @@ const createFieldset = (params?: (defaultParams: Props) => Props) => {
|
|
|
29
29
|
parameters = params(defaultParams);
|
|
30
30
|
}
|
|
31
31
|
const queries = render(<Fieldset {...parameters} data-testid="fieldset" />);
|
|
32
|
-
const fieldset = queries.getByTestId(
|
|
32
|
+
const fieldset = queries.getByTestId("fieldset");
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
35
|
...queries,
|
|
36
|
-
fieldset
|
|
36
|
+
fieldset
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
describe(
|
|
41
|
-
it(
|
|
40
|
+
describe("Fieldset should render", () => {
|
|
41
|
+
it("renders without crashing", () => {
|
|
42
42
|
const { fieldset } = createFieldset();
|
|
43
43
|
|
|
44
44
|
expect(fieldset).toBeTruthy();
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
describe(
|
|
49
|
-
it(
|
|
48
|
+
describe("ref should work", () => {
|
|
49
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
50
50
|
const ExampleComponent = ({
|
|
51
|
-
propagateRef
|
|
51
|
+
propagateRef
|
|
52
52
|
}: {
|
|
53
53
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
54
54
|
}) => {
|
|
@@ -64,46 +64,46 @@ describe('ref should work', () => {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
67
|
-
expect(ref.current).toHaveAttribute(
|
|
67
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
describe(
|
|
75
|
-
it(
|
|
76
|
-
const { fieldset } = createFieldset(
|
|
74
|
+
describe("Fieldset should get proper attributes and classes", () => {
|
|
75
|
+
it("has no padding class", () => {
|
|
76
|
+
const { fieldset } = createFieldset(defaultParams => ({ ...defaultParams, noPadding: true }));
|
|
77
77
|
|
|
78
|
-
expect(fieldset).toHaveClass(
|
|
78
|
+
expect(fieldset).toHaveClass("no-padding");
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
it(
|
|
82
|
-
const { fieldset } = createFieldset(
|
|
81
|
+
it("has no background styling", () => {
|
|
82
|
+
const { fieldset } = createFieldset(defaultParams => ({
|
|
83
83
|
...defaultParams,
|
|
84
|
-
noBackground: true
|
|
84
|
+
noBackground: true
|
|
85
85
|
}));
|
|
86
86
|
|
|
87
|
-
expect(fieldset.style.backgroundColor).toBe(
|
|
87
|
+
expect(fieldset.style.backgroundColor).toBe("");
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
it(
|
|
90
|
+
it("has a correct legend and title <span> element", () => {
|
|
91
91
|
const { getByText } = createFieldset();
|
|
92
92
|
|
|
93
|
-
const legend = getByText(/example/i, { selector:
|
|
94
|
-
const title = getByText(/example/i, { selector:
|
|
93
|
+
const legend = getByText(/example/i, { selector: "legend" });
|
|
94
|
+
const title = getByText(/example/i, { selector: "span" });
|
|
95
95
|
|
|
96
|
-
expect(legend).toHaveTextContent(
|
|
96
|
+
expect(legend).toHaveTextContent("Example");
|
|
97
97
|
expect(legend).toBeTruthy();
|
|
98
|
-
expect(title).toHaveClass(
|
|
98
|
+
expect(title).toHaveClass("typography_style_h2");
|
|
99
99
|
expect(title).toBeTruthy();
|
|
100
|
-
expect(title).toHaveTextContent(
|
|
100
|
+
expect(title).toHaveTextContent("Example");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
it(
|
|
103
|
+
it("renders its children correctly", () => {
|
|
104
104
|
const { getAllByTestId } = createFieldset();
|
|
105
105
|
|
|
106
|
-
const formcontrols = getAllByTestId(
|
|
106
|
+
const formcontrols = getAllByTestId("form-control");
|
|
107
107
|
|
|
108
108
|
expect(formcontrols).toBeTruthy();
|
|
109
109
|
expect(formcontrols).toHaveLength(2);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, ReactNode, ReactElement } from
|
|
2
|
-
import readyclasses from
|
|
3
|
-
import classes from
|
|
4
|
-
import { Typography, Variant } from
|
|
5
|
-
import { Input } from
|
|
6
|
-
import { Select } from
|
|
7
|
-
import { Radio } from
|
|
8
|
-
import { Checkbox } from
|
|
9
|
-
import { Textarea } from
|
|
10
|
-
import { Toggle } from
|
|
11
|
-
import { Label } from
|
|
12
|
-
import { FormControl } from
|
|
13
|
-
import { FormSelectorWrapper } from
|
|
14
|
-
import { FormHelperText } from
|
|
15
|
-
import { InputWrapper } from
|
|
16
|
-
import { SelectWrapper } from
|
|
17
|
-
import { TextareaWrapper } from
|
|
1
|
+
import React, { ComponentPropsWithRef, ReactNode, ReactElement } from "react";
|
|
2
|
+
import readyclasses from "../../readyclasses.module.scss";
|
|
3
|
+
import classes from "./Fieldset.module.scss";
|
|
4
|
+
import { Typography, Variant } from "../../Typography/Typography";
|
|
5
|
+
import { Input } from "../Input/Input";
|
|
6
|
+
import { Select } from "../Select/Select";
|
|
7
|
+
import { Radio } from "../Radio/Radio";
|
|
8
|
+
import { Checkbox } from "../Checkbox/Checkbox";
|
|
9
|
+
import { Textarea } from "../Textarea/Textarea";
|
|
10
|
+
import { Toggle } from "../Toggle/Toggle";
|
|
11
|
+
import { Label } from "../Label/Label";
|
|
12
|
+
import { FormControl } from "../FormControl/FormControl";
|
|
13
|
+
import { FormSelectorWrapper } from "../FormSelectorWrapper/FormSelectorWrapper";
|
|
14
|
+
import { FormHelperText } from "../FormHelperText/FormHelperText";
|
|
15
|
+
import { InputWrapper } from "../Wrapper/InputWrapper/InputWrapper";
|
|
16
|
+
import { SelectWrapper } from "../Wrapper/SelectWrapper/SelectWrapper";
|
|
17
|
+
import { TextareaWrapper } from "../Wrapper/TextareaWrapper/TextareaWrapper";
|
|
18
18
|
|
|
19
|
-
export interface Props extends ComponentPropsWithRef<
|
|
19
|
+
export interface Props extends ComponentPropsWithRef<"fieldset"> {
|
|
20
20
|
children?: ReactElement | ReactElement[];
|
|
21
21
|
legend: string;
|
|
22
22
|
legendStyle?: Variant;
|
|
@@ -35,10 +35,10 @@ export const Fieldset = React.forwardRef<HTMLFieldSetElement, Props>(
|
|
|
35
35
|
children,
|
|
36
36
|
className,
|
|
37
37
|
legend,
|
|
38
|
-
legendStyle =
|
|
38
|
+
legendStyle = "body",
|
|
39
39
|
hideLegend = false,
|
|
40
40
|
noBackground,
|
|
41
|
-
background = noBackground ?
|
|
41
|
+
background = noBackground ? "" : "#FFF",
|
|
42
42
|
noPadding = false,
|
|
43
43
|
disabled = false,
|
|
44
44
|
required = false,
|
|
@@ -68,14 +68,14 @@ export const Fieldset = React.forwardRef<HTMLFieldSetElement, Props>(
|
|
|
68
68
|
FormHelperText,
|
|
69
69
|
InputWrapper,
|
|
70
70
|
SelectWrapper,
|
|
71
|
-
TextareaWrapper
|
|
71
|
+
TextareaWrapper
|
|
72
72
|
];
|
|
73
73
|
|
|
74
74
|
return React.Children.map(children, (child: ReactElement) => {
|
|
75
75
|
if (allowedComponents.includes(child.type) && !disablePropagation) {
|
|
76
76
|
return React.cloneElement(child, {
|
|
77
77
|
disabled: child.props.disabled ?? disabled,
|
|
78
|
-
error: child.props.error ?? error
|
|
78
|
+
error: child.props.error ?? error
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -89,18 +89,18 @@ export const Fieldset = React.forwardRef<HTMLFieldSetElement, Props>(
|
|
|
89
89
|
ref={ref}
|
|
90
90
|
disabled={disabled}
|
|
91
91
|
style={{ backgroundColor: background, ...rest.style }}
|
|
92
|
-
className={`${classes.fieldset} ${noPadding ? classes[
|
|
93
|
-
className ??
|
|
92
|
+
className={`${classes.fieldset} ${noPadding ? classes["no-padding"] : ""} ${
|
|
93
|
+
className ?? ""
|
|
94
94
|
}`}
|
|
95
95
|
>
|
|
96
|
-
{legend && <legend className={readyclasses[
|
|
96
|
+
{legend && <legend className={readyclasses["sr-only"]}>{legend}</legend>}
|
|
97
97
|
{legend && !hideLegend && (
|
|
98
98
|
<Typography
|
|
99
99
|
variant={legendStyle}
|
|
100
100
|
tag="span"
|
|
101
101
|
aria-hidden="true"
|
|
102
|
-
className={`${classes[
|
|
103
|
-
error ? classes[
|
|
102
|
+
className={`${classes["legend"]} ${required ? classes["required"] : ""} ${
|
|
103
|
+
error ? classes["error"] : ""
|
|
104
104
|
}`}
|
|
105
105
|
>
|
|
106
106
|
{legend}
|
package/src/Form/Form.test.tsx
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Form } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Button } from
|
|
5
|
-
import userEvent from
|
|
6
|
-
|
|
7
|
-
describe(
|
|
8
|
-
it(
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Form } from "./Form";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { Button } from "../Button/Button";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
6
|
+
|
|
7
|
+
describe("Form should render", () => {
|
|
8
|
+
it("renders without crashing", () => {
|
|
9
9
|
const { getByTestId } = render(<Form data-testid="component">Content</Form>);
|
|
10
|
-
const component = getByTestId(
|
|
10
|
+
const component = getByTestId("component");
|
|
11
11
|
expect(component).toBeDefined();
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
describe(
|
|
16
|
-
it(
|
|
15
|
+
describe("Event should fire", () => {
|
|
16
|
+
it("should fire the onSubmitHandler function", () => {
|
|
17
17
|
const onSubmitHandler = jest.fn();
|
|
18
18
|
|
|
19
|
-
onSubmitHandler.mockImplementation(
|
|
19
|
+
onSubmitHandler.mockImplementation(event => {
|
|
20
20
|
event.preventDefault();
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -26,22 +26,22 @@ describe('Event should fire', () => {
|
|
|
26
26
|
</Form>
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
const button = getByTestId(
|
|
29
|
+
const button = getByTestId("submit-button");
|
|
30
30
|
userEvent.click(button);
|
|
31
31
|
expect(onSubmitHandler).toHaveBeenCalled();
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
describe(
|
|
35
|
+
describe("Should be able to set some default form properties", () => {
|
|
36
36
|
const { getByTestId } = render(
|
|
37
37
|
<Form data-testid="form" method="POST" action="./test.php">
|
|
38
38
|
Test
|
|
39
39
|
</Form>
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const form = getByTestId(
|
|
42
|
+
const form = getByTestId("form");
|
|
43
43
|
|
|
44
|
-
expect(form.getAttribute(
|
|
45
|
-
expect(form.getAttribute(
|
|
46
|
-
expect(form.innerHTML).toBe(
|
|
44
|
+
expect(form.getAttribute("method")).toBe("POST");
|
|
45
|
+
expect(form.getAttribute("action")).toBe("./test.php");
|
|
46
|
+
expect(form.innerHTML).toBe("Test");
|
|
47
47
|
});
|
package/src/Form/Form.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { HTMLProps, ReactNode } from
|
|
2
|
-
import classes from
|
|
1
|
+
import React, { HTMLProps, ReactNode } from "react";
|
|
2
|
+
import classes from "./Form.module.scss";
|
|
3
3
|
|
|
4
4
|
export interface Props extends HTMLProps<HTMLFormElement> {
|
|
5
5
|
children?: ReactNode;
|
|
@@ -7,7 +7,7 @@ export interface Props extends HTMLProps<HTMLFormElement> {
|
|
|
7
7
|
|
|
8
8
|
export const Form = ({ children, className, ...rest }: Props) => {
|
|
9
9
|
return (
|
|
10
|
-
<form className={`${classes.form} ${className ??
|
|
10
|
+
<form className={`${classes.form} ${className ?? ""}`} {...rest}>
|
|
11
11
|
{children}
|
|
12
12
|
</form>
|
|
13
13
|
);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { FormControl, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Input } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { FormControl, Props } from "./FormControl";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { Input } from "../Input/Input";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
7
|
grid: 3,
|
|
8
|
-
align:
|
|
8
|
+
align: "center",
|
|
9
9
|
children: [
|
|
10
10
|
<Input placeholder="This is a placeholder" name="example" data-testid="input" type="text" />,
|
|
11
11
|
<Input placeholder="This is a placeholder" name="example" data-testid="input" type="text" />,
|
|
12
|
-
<Input placeholder="This is a placeholder" name="example" data-testid="input" type="text"
|
|
13
|
-
]
|
|
12
|
+
<Input placeholder="This is a placeholder" name="example" data-testid="input" type="text" />
|
|
13
|
+
]
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const createFormControl = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -19,26 +19,26 @@ const createFormControl = (params?: (defaultParams: Props) => Props) => {
|
|
|
19
19
|
parameters = params(defaultParams);
|
|
20
20
|
}
|
|
21
21
|
const queries = render(<FormControl {...parameters} data-testid="formcontrol" />);
|
|
22
|
-
const formcontrol = queries.getByTestId(
|
|
22
|
+
const formcontrol = queries.getByTestId("formcontrol");
|
|
23
23
|
|
|
24
24
|
return {
|
|
25
25
|
...queries,
|
|
26
|
-
formcontrol
|
|
26
|
+
formcontrol
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
describe(
|
|
31
|
-
it(
|
|
30
|
+
describe("FormControl should render", () => {
|
|
31
|
+
it("renders without crashing", () => {
|
|
32
32
|
const { formcontrol } = createFormControl();
|
|
33
33
|
|
|
34
34
|
expect(formcontrol).toBeTruthy();
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
describe(
|
|
39
|
-
it(
|
|
38
|
+
describe("ref should work", () => {
|
|
39
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
40
40
|
const ExampleComponent = ({
|
|
41
|
-
propagateRef
|
|
41
|
+
propagateRef
|
|
42
42
|
}: {
|
|
43
43
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
44
44
|
}) => {
|
|
@@ -54,27 +54,27 @@ describe('ref should work', () => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
57
|
-
expect(ref.current).toHaveAttribute(
|
|
57
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
describe(
|
|
65
|
-
it(
|
|
64
|
+
describe("FormControl attributes should be working correctly", () => {
|
|
65
|
+
it("has the right classes and attributes", () => {
|
|
66
66
|
const { formcontrol } = createFormControl();
|
|
67
67
|
|
|
68
|
-
expect(formcontrol).toHaveClass(
|
|
69
|
-
expect(formcontrol.firstChild).toHaveClass(
|
|
68
|
+
expect(formcontrol).toHaveClass("grid");
|
|
69
|
+
expect(formcontrol.firstChild).toHaveClass("col-3");
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
describe(
|
|
74
|
-
it(
|
|
73
|
+
describe("FormControl children should render properly", () => {
|
|
74
|
+
it("renders children", () => {
|
|
75
75
|
const { getAllByTestId } = createFormControl();
|
|
76
76
|
|
|
77
|
-
const inputs = getAllByTestId(
|
|
77
|
+
const inputs = getAllByTestId("input");
|
|
78
78
|
|
|
79
79
|
expect(inputs).toBeTruthy();
|
|
80
80
|
expect(inputs).toHaveLength(3);
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, ReactElement } from
|
|
2
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef, ReactElement } from "react";
|
|
2
|
+
import classes from "./FormControl.module.scss";
|
|
3
3
|
|
|
4
|
-
export interface Props extends ComponentPropsWithRef<
|
|
4
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
5
5
|
children?: ReactElement | ReactElement[];
|
|
6
6
|
grid?: 1 | 2 | 3;
|
|
7
|
-
align?:
|
|
7
|
+
align?: "top" | "start" | "middle" | "center" | "bottom" | "end" | "stretch";
|
|
8
8
|
error?: boolean;
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const FormControl = React.forwardRef<HTMLDivElement, Props>(
|
|
13
|
-
({ children, disabled, error, className, grid, align =
|
|
13
|
+
({ children, disabled, error, className, grid, align = "center", ...rest }: Props, ref) => {
|
|
14
14
|
const renderChildren = () =>
|
|
15
|
-
React.Children.map(children,
|
|
15
|
+
React.Children.map(children, child => {
|
|
16
16
|
if (!child) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const childElement = React.cloneElement(child, {
|
|
21
21
|
disabled: child.props.disabled !== undefined ? child.props.disabled : disabled,
|
|
22
|
-
error: child.props.error !== undefined ? child.props.error : error
|
|
22
|
+
error: child.props.error !== undefined ? child.props.error : error
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
if (grid && grid > 1) {
|
|
26
26
|
return (
|
|
27
|
-
<div className={`${classes[
|
|
27
|
+
<div className={`${classes["col-" + grid]} ${classes.column}`}>{childElement}</div>
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -36,8 +36,8 @@ export const FormControl = React.forwardRef<HTMLDivElement, Props>(
|
|
|
36
36
|
{...rest}
|
|
37
37
|
ref={ref}
|
|
38
38
|
data-formcontrol
|
|
39
|
-
className={`${classes[
|
|
40
|
-
grid && grid > 1 ? `${classes.grid} ${classes[
|
|
39
|
+
className={`${classes["form-control"]} ${className ? className : ""} ${
|
|
40
|
+
grid && grid > 1 ? `${classes.grid} ${classes["grid-" + grid]}` : ""
|
|
41
41
|
} ${classes[align]}`}
|
|
42
42
|
>
|
|
43
43
|
{renderChildren()}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { FormGroup, Props } from
|
|
3
|
-
import { render } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { FormGroup, Props } from "./FormGroup";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
|
|
5
5
|
const defaultParams: Props = {
|
|
6
|
-
children:
|
|
7
|
-
helperId:
|
|
8
|
-
helperText:
|
|
9
|
-
errorMessage:
|
|
10
|
-
errorId:
|
|
6
|
+
children: "Formcontent here",
|
|
7
|
+
helperId: "helper_id",
|
|
8
|
+
helperText: "example helper text",
|
|
9
|
+
errorMessage: "example error message",
|
|
10
|
+
errorId: "error_id"
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const createFormGroup = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -16,38 +16,38 @@ const createFormGroup = (params?: (defaultParams: Props) => Props) => {
|
|
|
16
16
|
parameters = params(defaultParams);
|
|
17
17
|
}
|
|
18
18
|
const queries = render(<FormGroup {...parameters} data-testid="formgroup"></FormGroup>);
|
|
19
|
-
const formgroup = queries.getByTestId(
|
|
19
|
+
const formgroup = queries.getByTestId("formgroup");
|
|
20
20
|
|
|
21
21
|
return {
|
|
22
22
|
...queries,
|
|
23
|
-
formgroup
|
|
23
|
+
formgroup
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
describe(
|
|
28
|
-
it(
|
|
27
|
+
describe("FormSelectorGroup should render", () => {
|
|
28
|
+
it("renders without crashing", () => {
|
|
29
29
|
const { formgroup } = createFormGroup();
|
|
30
30
|
|
|
31
31
|
expect(formgroup).toBeDefined();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
it(
|
|
35
|
-
const { getByTestId } = createFormGroup(
|
|
34
|
+
it("has the correct values and attributes", () => {
|
|
35
|
+
const { getByTestId } = createFormGroup(defaultParams => ({
|
|
36
36
|
...defaultParams,
|
|
37
|
-
helperProps: {
|
|
37
|
+
helperProps: { "data-testid": "helper_text" }
|
|
38
38
|
}));
|
|
39
39
|
|
|
40
|
-
const helperText = getByTestId(
|
|
40
|
+
const helperText = getByTestId("helper_text");
|
|
41
41
|
|
|
42
|
-
expect(helperText).toHaveAttribute(
|
|
43
|
-
expect(helperText).toHaveTextContent(
|
|
42
|
+
expect(helperText).toHaveAttribute("id", "helper_id");
|
|
43
|
+
expect(helperText).toHaveTextContent("example helper text");
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
describe(
|
|
48
|
-
it(
|
|
47
|
+
describe("ref should work", () => {
|
|
48
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
49
49
|
const ExampleComponent = ({
|
|
50
|
-
propagateRef
|
|
50
|
+
propagateRef
|
|
51
51
|
}: {
|
|
52
52
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
53
53
|
}) => {
|
|
@@ -63,49 +63,49 @@ describe('ref should work', () => {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
66
|
-
expect(ref.current).toHaveAttribute(
|
|
66
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
describe(
|
|
74
|
-
it(
|
|
75
|
-
const { formgroup } = createFormGroup(
|
|
73
|
+
describe("Correct error state", () => {
|
|
74
|
+
it("has the correct state", () => {
|
|
75
|
+
const { formgroup } = createFormGroup(defaultParams => ({
|
|
76
76
|
...defaultParams,
|
|
77
77
|
error: true,
|
|
78
|
-
errorMessage:
|
|
79
|
-
errorId:
|
|
78
|
+
errorMessage: "example error message",
|
|
79
|
+
errorId: "error_id"
|
|
80
80
|
}));
|
|
81
|
-
const errorMessage = formgroup.querySelector(
|
|
81
|
+
const errorMessage = formgroup.querySelector(".error-message");
|
|
82
82
|
|
|
83
83
|
expect(errorMessage).toBeTruthy();
|
|
84
|
-
expect(errorMessage?.querySelector(
|
|
85
|
-
expect(errorMessage?.querySelector(
|
|
84
|
+
expect(errorMessage?.querySelector("#error_id")).toBeTruthy();
|
|
85
|
+
expect(errorMessage?.querySelector("#error_id")).toHaveTextContent("example error message");
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
describe(
|
|
89
|
+
describe("no helpertext, but errorMessage is defined", () => {
|
|
90
90
|
it("doesn't show the div with 'default-helper' class when there's no error and no helpertext defined", () => {
|
|
91
|
-
const { formgroup } = createFormGroup(
|
|
91
|
+
const { formgroup } = createFormGroup(defaultParams => ({
|
|
92
92
|
...defaultParams,
|
|
93
93
|
error: false,
|
|
94
94
|
helperText: undefined,
|
|
95
|
-
errorMessage:
|
|
95
|
+
errorMessage: "example error message"
|
|
96
96
|
}));
|
|
97
97
|
|
|
98
|
-
expect(formgroup.querySelector(
|
|
98
|
+
expect(formgroup.querySelector(".default-helper")).toBeFalsy();
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
it("does show the div with 'default-helper' class when there's an error and no helpertext defined", () => {
|
|
102
|
-
const { formgroup } = createFormGroup(
|
|
102
|
+
const { formgroup } = createFormGroup(defaultParams => ({
|
|
103
103
|
...defaultParams,
|
|
104
104
|
error: true,
|
|
105
105
|
helperText: undefined,
|
|
106
|
-
errorMessage:
|
|
106
|
+
errorMessage: "example error message"
|
|
107
107
|
}));
|
|
108
108
|
|
|
109
|
-
expect(formgroup.querySelector(
|
|
109
|
+
expect(formgroup.querySelector(".default-helper")).toBeTruthy();
|
|
110
110
|
});
|
|
111
111
|
});
|