@onewelcome/react-lib-components 0.2.1 → 0.2.2
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 +672 -576
- 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 +672 -576
- 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 +81 -76
- package/src/ContextMenu/ContextMenu.tsx +43 -41
- package/src/ContextMenu/ContextMenuItem.module.scss +1 -1
- package/src/ContextMenu/ContextMenuItem.tsx +5 -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 +86 -59
- 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 +10 -10
- 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
package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { DiscardChangesDialog, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { DiscardChangesDialog, Props } from "./DiscardChangesDialog";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
7
|
open: true,
|
|
8
8
|
onKeepEditing: jest.fn(),
|
|
9
9
|
onDiscardChanges: jest.fn(),
|
|
10
|
-
discardChangesButtonLabel:
|
|
11
|
-
keepEditingButtonLabel:
|
|
12
|
-
contentLabel:
|
|
13
|
-
titleLabel:
|
|
10
|
+
discardChangesButtonLabel: "Discard Changes",
|
|
11
|
+
keepEditingButtonLabel: "Keep Editing",
|
|
12
|
+
contentLabel: "Content",
|
|
13
|
+
titleLabel: "Unsaved changes"
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const createDiscardChangesDialog = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -21,24 +21,24 @@ const createDiscardChangesDialog = (params?: (defaultParams: Props) => Props) =>
|
|
|
21
21
|
const queries = render(
|
|
22
22
|
<DiscardChangesDialog {...parameters} data-testid="DiscardChangesDialog"></DiscardChangesDialog>
|
|
23
23
|
);
|
|
24
|
-
const discardChangesDialog = queries.getByTestId(
|
|
25
|
-
const discardChangesBtn = queries.getByRole(
|
|
26
|
-
name: defaultParams.discardChangesButtonLabel
|
|
24
|
+
const discardChangesDialog = queries.getByTestId("DiscardChangesDialog");
|
|
25
|
+
const discardChangesBtn = queries.getByRole("button", {
|
|
26
|
+
name: defaultParams.discardChangesButtonLabel
|
|
27
27
|
});
|
|
28
|
-
const keepEditingBtn = queries.getByRole(
|
|
29
|
-
name: defaultParams.keepEditingButtonLabel
|
|
28
|
+
const keepEditingBtn = queries.getByRole("button", {
|
|
29
|
+
name: defaultParams.keepEditingButtonLabel
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
33
|
...queries,
|
|
34
34
|
discardChangesDialog,
|
|
35
35
|
discardChangesBtn,
|
|
36
|
-
keepEditingBtn
|
|
36
|
+
keepEditingBtn
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
describe(
|
|
41
|
-
it(
|
|
40
|
+
describe("DiscardChangesDialog should render", () => {
|
|
41
|
+
it("renders without crashing", () => {
|
|
42
42
|
const { discardChangesDialog, discardChangesBtn, keepEditingBtn } =
|
|
43
43
|
createDiscardChangesDialog();
|
|
44
44
|
|
|
@@ -54,10 +54,10 @@ describe('DiscardChangesDialog should render', () => {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
describe(
|
|
58
|
-
it(
|
|
57
|
+
describe("ref should work", () => {
|
|
58
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
59
59
|
const ExampleComponent = ({
|
|
60
|
-
propagateRef
|
|
60
|
+
propagateRef
|
|
61
61
|
}: {
|
|
62
62
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
63
63
|
}) => {
|
|
@@ -87,7 +87,7 @@ describe('ref should work', () => {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
90
|
-
expect(ref.current).toHaveAttribute(
|
|
90
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
2
|
-
import { Dialog } from
|
|
3
|
-
import { Typography } from
|
|
4
|
-
import { DataAttributeKey } from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
|
+
import { Dialog } from "../../Dialog/Dialog";
|
|
3
|
+
import { Typography } from "../../../Typography/Typography";
|
|
4
|
+
import { DataAttributeKey } from "../../../interfaces";
|
|
5
5
|
|
|
6
|
-
export interface Props extends ComponentPropsWithRef<
|
|
6
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
7
7
|
open: boolean;
|
|
8
8
|
discardChangesButtonLabel: string;
|
|
9
9
|
keepEditingButtonLabel: string;
|
|
@@ -38,11 +38,11 @@ export const DiscardChangesDialog = React.forwardRef<HTMLDivElement, Props>(
|
|
|
38
38
|
onClose={onKeepEditing}
|
|
39
39
|
primaryAction={{
|
|
40
40
|
label: discardChangesButtonLabel,
|
|
41
|
-
onClick: onDiscardChanges
|
|
41
|
+
onClick: onDiscardChanges
|
|
42
42
|
}}
|
|
43
43
|
secondaryAction={{
|
|
44
44
|
label: keepEditingButtonLabel,
|
|
45
|
-
onClick: onKeepEditing
|
|
45
|
+
onClick: onKeepEditing
|
|
46
46
|
}}
|
|
47
47
|
disableEscapeKeyDown={false}
|
|
48
48
|
>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { DiscardChangesModal, Props } from
|
|
3
|
-
import { findByTestId, getAllByRole, render, waitFor } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { DiscardChangesModal, Props } from "./DiscardChangesModal";
|
|
3
|
+
import { findByTestId, getAllByRole, render, waitFor } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
|
-
id:
|
|
7
|
+
id: "modal",
|
|
8
8
|
open: true,
|
|
9
9
|
hasUnsavedChanges: jest.fn(),
|
|
10
10
|
onClose: jest.fn(),
|
|
11
11
|
headerProps: {
|
|
12
|
-
title:
|
|
12
|
+
title: "Header"
|
|
13
13
|
},
|
|
14
14
|
discardChangedDialogProps: {
|
|
15
|
-
|
|
16
|
-
discardChangesButtonLabel:
|
|
17
|
-
keepEditingButtonLabel:
|
|
18
|
-
contentLabel:
|
|
19
|
-
titleLabel:
|
|
15
|
+
"data-testid": "discardChangesDialog",
|
|
16
|
+
discardChangesButtonLabel: "Discard",
|
|
17
|
+
keepEditingButtonLabel: "Keep editing",
|
|
18
|
+
contentLabel: "Unsaved changes",
|
|
19
|
+
titleLabel: "Dialog"
|
|
20
20
|
},
|
|
21
|
-
children: <span>children</span
|
|
21
|
+
children: <span>children</span>
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const createDiscardChangesModal = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -27,37 +27,37 @@ const createDiscardChangesModal = (params?: (defaultParams: Props) => Props) =>
|
|
|
27
27
|
parameters = params(defaultParams);
|
|
28
28
|
}
|
|
29
29
|
const queries = render(<DiscardChangesModal {...parameters} data-testid="discardChangesModal" />);
|
|
30
|
-
const discardChangesModal = queries.getByTestId(
|
|
31
|
-
const closeBtn = queries.getByRole(
|
|
30
|
+
const discardChangesModal = queries.getByTestId("discardChangesModal");
|
|
31
|
+
const closeBtn = queries.getByRole("button", { name: "close modal" });
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
34
|
...queries,
|
|
35
35
|
discardChangesModal,
|
|
36
|
-
closeBtn
|
|
36
|
+
closeBtn
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const getDiscardChangesButtons = (container: HTMLElement) =>
|
|
41
|
-
getAllByRole(container,
|
|
41
|
+
getAllByRole(container, "button", {
|
|
42
42
|
name: new RegExp(
|
|
43
43
|
`(${defaultParams.discardChangedDialogProps.discardChangesButtonLabel}|${defaultParams.discardChangedDialogProps.keepEditingButtonLabel})`
|
|
44
|
-
)
|
|
44
|
+
)
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
const findDiscardChangesDialog = (container: HTMLElement) =>
|
|
48
|
-
findByTestId(container,
|
|
48
|
+
findByTestId(container, "discardChangesDialog");
|
|
49
49
|
|
|
50
|
-
describe(
|
|
51
|
-
it(
|
|
50
|
+
describe("DiscardChangesModal should render", () => {
|
|
51
|
+
it("renders without crashing", () => {
|
|
52
52
|
const { discardChangesModal, container } = createDiscardChangesModal();
|
|
53
53
|
|
|
54
54
|
expect(discardChangesModal).toBeDefined();
|
|
55
|
-
expect(discardChangesModal).toHaveTextContent(
|
|
55
|
+
expect(discardChangesModal).toHaveTextContent("children");
|
|
56
56
|
expect(discardChangesModal).toHaveTextContent(defaultParams.headerProps.title);
|
|
57
57
|
expect(container).not.toHaveTextContent(defaultParams.discardChangedDialogProps.titleLabel);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it(
|
|
60
|
+
it("clicking on close button without making any changes close the modal", () => {
|
|
61
61
|
(
|
|
62
62
|
defaultParams.hasUnsavedChanges as jest.MockedFunction<typeof defaultParams.hasUnsavedChanges>
|
|
63
63
|
).mockReturnValue(false);
|
|
@@ -68,8 +68,8 @@ describe('DiscardChangesModal should render', () => {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
describe(
|
|
72
|
-
it(
|
|
71
|
+
describe("DiscardChangesModal should show DiscardChangesDialog", () => {
|
|
72
|
+
it("showing DiscardChangesDialog and clicking on `keep editing` button", async () => {
|
|
73
73
|
(
|
|
74
74
|
defaultParams.hasUnsavedChanges as jest.MockedFunction<typeof defaultParams.hasUnsavedChanges>
|
|
75
75
|
).mockReturnValue(true);
|
|
@@ -92,7 +92,7 @@ describe('DiscardChangesModal should show DiscardChangesDialog', () => {
|
|
|
92
92
|
);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
it(
|
|
95
|
+
it("showing DiscardChangesDialog and clicking on `discard` button", async () => {
|
|
96
96
|
(
|
|
97
97
|
defaultParams.hasUnsavedChanges as jest.MockedFunction<typeof defaultParams.hasUnsavedChanges>
|
|
98
98
|
).mockReturnValue(true);
|
|
@@ -110,10 +110,10 @@ describe('DiscardChangesModal should show DiscardChangesDialog', () => {
|
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
describe(
|
|
114
|
-
it(
|
|
113
|
+
describe("ref should work", () => {
|
|
114
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
115
115
|
const ExampleComponent = ({
|
|
116
|
-
propagateRef
|
|
116
|
+
propagateRef
|
|
117
117
|
}: {
|
|
118
118
|
propagateRef?: (
|
|
119
119
|
ref1: React.RefObject<HTMLElement>,
|
|
@@ -136,15 +136,15 @@ describe('ref should work', () => {
|
|
|
136
136
|
data-ref="testing"
|
|
137
137
|
hasUnsavedChanges={jest.fn()}
|
|
138
138
|
onClose={jest.fn()}
|
|
139
|
-
headerProps={{ title:
|
|
139
|
+
headerProps={{ title: "test" }}
|
|
140
140
|
open={false}
|
|
141
141
|
children="test"
|
|
142
142
|
discardChangedDialogProps={{
|
|
143
|
-
contentLabel:
|
|
144
|
-
discardChangesButtonLabel:
|
|
145
|
-
keepEditingButtonLabel:
|
|
146
|
-
titleLabel:
|
|
147
|
-
|
|
143
|
+
contentLabel: "test",
|
|
144
|
+
discardChangesButtonLabel: "test",
|
|
145
|
+
keepEditingButtonLabel: "test",
|
|
146
|
+
titleLabel: "test",
|
|
147
|
+
"data-ref": "testing"
|
|
148
148
|
}}
|
|
149
149
|
title="test"
|
|
150
150
|
id="test"
|
|
@@ -153,8 +153,8 @@ describe('ref should work', () => {
|
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
const refCheck = (ref1: React.RefObject<HTMLElement>, ref2: React.RefObject<HTMLElement>) => {
|
|
156
|
-
expect(ref1.current).toHaveAttribute(
|
|
157
|
-
expect(ref2.current).toHaveAttribute(
|
|
156
|
+
expect(ref1.current).toHaveAttribute("data-ref", "testing");
|
|
157
|
+
expect(ref2.current).toHaveAttribute("data-ref", "testing");
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React, { Fragment, useState } from
|
|
2
|
-
import { Modal, Props as ModalProps } from
|
|
3
|
-
import { ModalHeader, Props as ModalHeaderProps } from
|
|
1
|
+
import React, { Fragment, useState } from "react";
|
|
2
|
+
import { Modal, Props as ModalProps } from "../Modal/Modal";
|
|
3
|
+
import { ModalHeader, Props as ModalHeaderProps } from "../Modal/ModalHeader/ModalHeader";
|
|
4
4
|
import {
|
|
5
5
|
DiscardChangesDialog,
|
|
6
|
-
Props as DiscardChangesDialogProps
|
|
7
|
-
} from
|
|
6
|
+
Props as DiscardChangesDialogProps
|
|
7
|
+
} from "./DiscardChangesDialog/DiscardChangesDialog";
|
|
8
8
|
|
|
9
|
-
export interface Props extends Omit<ModalProps,
|
|
9
|
+
export interface Props extends Omit<ModalProps, "onClose"> {
|
|
10
10
|
hasUnsavedChanges: () => boolean;
|
|
11
11
|
onClose: (event?: React.MouseEvent<HTMLElement>) => unknown;
|
|
12
|
-
headerProps: Omit<ModalHeaderProps,
|
|
12
|
+
headerProps: Omit<ModalHeaderProps, "onClose" | "id">;
|
|
13
13
|
discardChangedDialogProps: Omit<
|
|
14
14
|
DiscardChangesDialogProps,
|
|
15
|
-
|
|
15
|
+
"open" | "onKeepEditing" | "onDiscardChanges"
|
|
16
16
|
>;
|
|
17
17
|
modalRef?: React.RefObject<HTMLDivElement>;
|
|
18
18
|
dialogRef?: React.RefObject<HTMLDivElement>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import * as ReactDOM from
|
|
3
|
-
import { Modal } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as ReactDOM from "react-dom";
|
|
3
|
+
import { Modal } from "./Modal";
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
it(
|
|
7
|
-
const div = document.createElement(
|
|
5
|
+
describe("Modal", () => {
|
|
6
|
+
it("renders without crashing", () => {
|
|
7
|
+
const div = document.createElement("div");
|
|
8
8
|
ReactDOM.render(
|
|
9
9
|
<Modal id="modal" open={true} onClose={() => {}}>
|
|
10
10
|
test
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BaseModal as Modal, Props } from
|
|
1
|
+
export { BaseModal as Modal, Props } from "../BaseModal/BaseModal";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { SlideInModal } from
|
|
3
|
-
import { Props } from
|
|
4
|
-
import { render, fireEvent } from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { SlideInModal } from "./SlideInModal";
|
|
3
|
+
import { Props } from "../Modal/Modal";
|
|
4
|
+
import { render, fireEvent } from "@testing-library/react";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
|
-
id:
|
|
7
|
+
id: "",
|
|
8
8
|
children: undefined,
|
|
9
|
-
open: false
|
|
9
|
+
open: false
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const createSlideInModal = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -15,16 +15,16 @@ const createSlideInModal = (params?: (defaultParams: Props) => Props) => {
|
|
|
15
15
|
parameters = params(defaultParams);
|
|
16
16
|
}
|
|
17
17
|
const queries = render(<SlideInModal {...parameters} data-testid="SlideInModal" />);
|
|
18
|
-
const slideInModal = queries.getByTestId(
|
|
18
|
+
const slideInModal = queries.getByTestId("SlideInModal");
|
|
19
19
|
|
|
20
20
|
return {
|
|
21
21
|
...queries,
|
|
22
|
-
slideInModal
|
|
22
|
+
slideInModal
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
describe(
|
|
27
|
-
it(
|
|
26
|
+
describe("SlideInModal should render", () => {
|
|
27
|
+
it("renders without crashing", () => {
|
|
28
28
|
const { slideInModal } = createSlideInModal();
|
|
29
29
|
|
|
30
30
|
expect(slideInModal).toBeDefined();
|
|
@@ -33,19 +33,19 @@ describe('SlideInModal should render', () => {
|
|
|
33
33
|
it("makes modal content's container visible after opening transition ends", () => {
|
|
34
34
|
const { slideInModal, rerender } = createSlideInModal();
|
|
35
35
|
|
|
36
|
-
expect(slideInModal).toHaveClass(
|
|
36
|
+
expect(slideInModal).toHaveClass("hidden");
|
|
37
37
|
|
|
38
38
|
rerender(<SlideInModal {...defaultParams} open />);
|
|
39
39
|
fireEvent.transitionEnd(slideInModal);
|
|
40
40
|
|
|
41
|
-
expect(slideInModal).not.toHaveClass(
|
|
41
|
+
expect(slideInModal).not.toHaveClass("hidden");
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
describe(
|
|
46
|
-
it(
|
|
45
|
+
describe("ref should work", () => {
|
|
46
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
47
47
|
const ExampleComponent = ({
|
|
48
|
-
propagateRef
|
|
48
|
+
propagateRef
|
|
49
49
|
}: {
|
|
50
50
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
51
51
|
}) => {
|
|
@@ -61,7 +61,7 @@ describe('ref should work', () => {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
64
|
-
expect(ref.current).toHaveAttribute(
|
|
64
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { Props as ModalProps, Modal } from
|
|
3
|
-
import classes from
|
|
1
|
+
import React, { TransitionEventHandler, useState, useRef } from "react";
|
|
2
|
+
import { Props as ModalProps, Modal } from "../Modal/Modal";
|
|
3
|
+
import classes from "./SlideInModal.module.scss";
|
|
4
4
|
|
|
5
5
|
export const SlideInModal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
6
6
|
({ children, id, open, ...rest }: ModalProps, ref) => {
|
|
7
|
-
const [classHideOnTransition, setClassHideOnTransition] = useState<
|
|
7
|
+
const [classHideOnTransition, setClassHideOnTransition] = useState<string>("hidden");
|
|
8
|
+
const containerRef = useRef(null);
|
|
8
9
|
|
|
9
|
-
const onTransitionEnd =
|
|
10
|
+
const onTransitionEnd: TransitionEventHandler<HTMLDivElement> = e => {
|
|
11
|
+
if (e.target === containerRef.current) {
|
|
12
|
+
setClassHideOnTransition(prev => (prev ? "" : "hidden"));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
10
15
|
|
|
11
16
|
return (
|
|
12
17
|
<Modal
|
|
13
18
|
{...rest}
|
|
14
19
|
id={id}
|
|
15
20
|
open={open}
|
|
16
|
-
className={`${classes[
|
|
17
|
-
!open ? classes[classHideOnTransition] :
|
|
21
|
+
className={`${classes["slide-in-modal"]} ${open ? classes["visible"] : ""} ${
|
|
22
|
+
!open ? classes[classHideOnTransition] : ""
|
|
18
23
|
}`}
|
|
19
|
-
containerProps={{ className: classes[
|
|
20
|
-
backdropProps={{ className: classes[
|
|
24
|
+
containerProps={{ className: classes["container"] }}
|
|
25
|
+
backdropProps={{ className: classes["backdrop-slide"] }}
|
|
21
26
|
forceContainerOpen
|
|
22
27
|
onTransitionEnd={onTransitionEnd}
|
|
23
|
-
ref={ref}
|
|
28
|
+
ref={ref || containerRef}
|
|
24
29
|
>
|
|
25
30
|
{children}
|
|
26
31
|
</Modal>
|
|
@@ -28,4 +33,4 @@ export const SlideInModal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
28
33
|
}
|
|
29
34
|
);
|
|
30
35
|
|
|
31
|
-
export { Props } from
|
|
36
|
+
export { Props } from "../Modal/Modal";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { SnackbarContainer, Props } from
|
|
3
|
-
import { render } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SnackbarContainer, Props } from "./SnackbarContainer";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
4
|
|
|
5
5
|
const defaultParams: Props = {
|
|
6
|
-
placement: { vertical:
|
|
7
|
-
children: <span>children</span
|
|
6
|
+
placement: { vertical: "top", horizontal: "center" },
|
|
7
|
+
children: <span>children</span>
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const createSnackbarContainer = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -13,25 +13,25 @@ const createSnackbarContainer = (params?: (defaultParams: Props) => Props) => {
|
|
|
13
13
|
parameters = params(defaultParams);
|
|
14
14
|
}
|
|
15
15
|
const queries = render(<SnackbarContainer {...parameters} data-testid="snackbarcontainer" />);
|
|
16
|
-
const snackbarcontainer = queries.getByTestId(
|
|
16
|
+
const snackbarcontainer = queries.getByTestId("snackbarcontainer");
|
|
17
17
|
return { ...queries, snackbarcontainer };
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
describe(
|
|
21
|
-
it(
|
|
20
|
+
describe("SnackbarContainer should render", () => {
|
|
21
|
+
it("renders without crashing", () => {
|
|
22
22
|
const { snackbarcontainer, getByText } = createSnackbarContainer();
|
|
23
|
-
expect(snackbarcontainer).toHaveClass(
|
|
24
|
-
expect(snackbarcontainer).toHaveClass(
|
|
25
|
-
expect(snackbarcontainer).toHaveStyle({ zIndex:
|
|
26
|
-
expect(getByText(
|
|
23
|
+
expect(snackbarcontainer).toHaveClass("top");
|
|
24
|
+
expect(snackbarcontainer).toHaveClass("center");
|
|
25
|
+
expect(snackbarcontainer).toHaveStyle({ zIndex: "" });
|
|
26
|
+
expect(getByText("children")).toBeDefined();
|
|
27
27
|
expect(snackbarcontainer).toBeDefined();
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it(
|
|
31
|
-
const { snackbarcontainer } = createSnackbarContainer(
|
|
30
|
+
it("renders with zIndex", () => {
|
|
31
|
+
const { snackbarcontainer } = createSnackbarContainer(defaultParams => ({
|
|
32
32
|
...defaultParams,
|
|
33
|
-
zIndex: 1
|
|
33
|
+
zIndex: 1
|
|
34
34
|
}));
|
|
35
|
-
expect(snackbarcontainer).toHaveStyle({ zIndex:
|
|
35
|
+
expect(snackbarcontainer).toHaveStyle({ zIndex: "1" });
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import classes from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classes from "./SnackbarContainer.module.scss";
|
|
3
3
|
|
|
4
4
|
export interface Placement {
|
|
5
|
-
vertical:
|
|
6
|
-
horizontal:
|
|
5
|
+
vertical: "top" | "bottom";
|
|
6
|
+
horizontal: "start" | "center" | "end";
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface Props {
|
|
@@ -18,9 +18,9 @@ export const SnackbarContainer = ({ placement, children, zIndex, className, ...r
|
|
|
18
18
|
<div
|
|
19
19
|
{...rest}
|
|
20
20
|
style={{ zIndex }}
|
|
21
|
-
className={`${classes[
|
|
21
|
+
className={`${classes["snackbars"]} ${classes[placement.horizontal]} ${
|
|
22
22
|
classes[placement.vertical]
|
|
23
|
-
} ${className ??
|
|
23
|
+
} ${className ?? ""}`}
|
|
24
24
|
>
|
|
25
25
|
{children}
|
|
26
26
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import "../../../readyclasses.module.scss";
|
|
2
2
|
|
|
3
3
|
.snackbar {
|
|
4
4
|
padding: 1rem 1.25rem;
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
calc(1.25rem + var(--button-border-width));
|
|
111
111
|
|
|
112
112
|
&:after {
|
|
113
|
-
content:
|
|
113
|
+
content: "";
|
|
114
114
|
position: absolute;
|
|
115
115
|
top: 0;
|
|
116
116
|
left: 0;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render, getByRole, waitFor } from
|
|
3
|
-
import { SnackbarItem, Props } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, getByRole, waitFor } from "@testing-library/react";
|
|
3
|
+
import { SnackbarItem, Props } from "./SnackbarItem";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const initParams: Props = {
|
|
7
|
-
id:
|
|
8
|
-
title:
|
|
7
|
+
id: "id",
|
|
8
|
+
title: "title",
|
|
9
9
|
duration: 1,
|
|
10
|
-
variant:
|
|
11
|
-
closeButtonTitle:
|
|
12
|
-
onClose: jest.fn()
|
|
10
|
+
variant: "success",
|
|
11
|
+
closeButtonTitle: "close",
|
|
12
|
+
onClose: jest.fn()
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
describe(
|
|
16
|
-
it(
|
|
15
|
+
describe("SnackbarItem", () => {
|
|
16
|
+
it("renders without crashing", () => {
|
|
17
17
|
const { container } = render(<SnackbarItem {...initParams} />);
|
|
18
18
|
|
|
19
19
|
expect(container).toHaveTextContent(initParams.title);
|
|
20
|
-
const contentDiv = container.querySelector(
|
|
20
|
+
const contentDiv = container.querySelector(".content");
|
|
21
21
|
expect(contentDiv).toBeNull();
|
|
22
|
-
const actionsDiv = container.querySelector(
|
|
22
|
+
const actionsDiv = container.querySelector(".actions");
|
|
23
23
|
expect(actionsDiv).toBeNull();
|
|
24
|
-
expect(getByRole(container,
|
|
24
|
+
expect(getByRole(container, "button")).toBeDefined();
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
it(
|
|
27
|
+
it("clicking close button call callback function", () => {
|
|
28
28
|
const { container } = render(<SnackbarItem {...initParams} duration={10000000} />);
|
|
29
29
|
|
|
30
30
|
expect(initParams.onClose).not.toBeCalled();
|
|
31
|
-
userEvent.click(getByRole(container,
|
|
31
|
+
userEvent.click(getByRole(container, "button"));
|
|
32
32
|
waitFor(() => {
|
|
33
33
|
expect(initParams.onClose).toBeCalledTimes(1);
|
|
34
34
|
expect(initParams.onClose).toHaveBeenCalledWith(initParams.id);
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it(
|
|
38
|
+
it("call close callback after provided duration", () => {
|
|
39
39
|
render(<SnackbarItem {...initParams} />);
|
|
40
40
|
|
|
41
41
|
expect(initParams.onClose).not.toBeCalled();
|