@onewelcome/react-lib-components 5.2.0 → 6.1.0
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/cjs/Button/BaseButton.cjs.js.map +1 -1
- package/dist/cjs/Button/BaseButton.module.cjs.js +1 -1
- package/dist/cjs/Button/Button.module.cjs.js +1 -1
- package/dist/cjs/Button/IconButton.module.cjs.js +1 -1
- package/dist/cjs/ContextMenu/ContextMenu.cjs.js +1 -1
- package/dist/cjs/ContextMenu/ContextMenu.cjs.js.map +1 -1
- package/dist/cjs/ContextMenu/ContextMenuItem.module.cjs.js +1 -1
- package/dist/cjs/ContextMenu/ContextMenuService.cjs.js +1 -1
- package/dist/cjs/ContextMenu/ContextMenuService.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridActions/DataGridColumnsToggle.module.cjs.js +1 -1
- package/dist/cjs/Form/Input/Input.module.cjs.js +1 -1
- package/dist/cjs/Form/Select/Option.cjs.js +1 -1
- package/dist/cjs/Form/Select/Option.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/Select.cjs.js +1 -1
- package/dist/cjs/Form/Select/Select.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/Select.module.cjs.js +1 -1
- package/dist/cjs/Form/Select/SelectService.cjs.js +1 -1
- package/dist/cjs/Form/Select/SelectService.cjs.js.map +1 -1
- package/dist/cjs/Form/Textarea/Textarea.module.cjs.js +1 -1
- package/dist/cjs/Icon/Icon.cjs.js +1 -1
- package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
- package/dist/cjs/Icon/Icon.module.cjs.js +1 -1
- package/dist/cjs/Link/Link.cjs.js.map +1 -1
- package/dist/cjs/Link/Link.module.cjs.js +1 -1
- package/dist/cjs/Notifications/BaseModal/BaseModal.module.cjs.js +1 -1
- package/dist/cjs/Notifications/SlideInModal/SlideInModal.module.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.cjs.js.map +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.cjs.js +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.cjs.js.map +1 -1
- package/dist/cjs/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.cjs.js.map +1 -1
- package/dist/cjs/Notifications/Snackbar/interfaces.cjs.js +2 -0
- package/dist/cjs/Notifications/Snackbar/interfaces.cjs.js.map +1 -0
- package/dist/cjs/Popover/Popover.cjs.js +1 -1
- package/dist/cjs/Popover/Popover.cjs.js.map +1 -1
- package/dist/cjs/Popover/Popover.module.cjs.js +1 -1
- package/dist/cjs/Stepper/Step.cjs.js +1 -1
- package/dist/cjs/Stepper/Step.cjs.js.map +1 -1
- package/dist/cjs/Stepper/Step.module.cjs.js +1 -1
- package/dist/cjs/Stepper/Stepper.cjs.js +1 -1
- package/dist/cjs/Stepper/Stepper.cjs.js.map +1 -1
- package/dist/cjs/Tabs/TabButton.module.cjs.js +1 -1
- package/dist/cjs/TextEllipsis/TextEllipsis.module.cjs.js +1 -1
- package/dist/cjs/Tiles/Tile.module.cjs.js +1 -1
- package/dist/cjs/Tooltip/Tooltip.module.cjs.js +1 -1
- package/dist/cjs/Wizard/BaseWizardSteps/BaseWizardSteps.module.cjs.js +1 -1
- package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js +1 -1
- package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js.map +1 -1
- package/dist/cjs/src/.scope.d.ts +2 -0
- package/dist/cjs/src/components/Button/BaseButton.d.ts +1 -1
- package/dist/cjs/src/components/ContextMenu/ContextMenu.d.ts +1 -1
- package/dist/cjs/src/components/ContextMenu/ContextMenuService.d.ts +4 -1
- package/dist/cjs/src/components/Form/Select/Option.d.ts +1 -0
- package/dist/cjs/src/components/Form/Select/Select.d.ts +20 -0
- package/dist/cjs/src/components/Form/Select/Select.interfaces.d.ts +3 -1
- package/dist/cjs/src/components/Form/Select/Select.test.d.ts +63 -1
- package/dist/cjs/src/components/Form/Select/SelectKeyboardNavigation.test.d.ts +1 -0
- package/dist/cjs/src/components/Form/Select/SelectService.d.ts +3 -2
- package/dist/cjs/src/components/Icon/Icon.d.ts +4 -1
- package/dist/cjs/src/components/Link/Link.d.ts +1 -1
- package/dist/cjs/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +5 -5
- package/dist/cjs/src/components/Notifications/Snackbar/interfaces.d.ts +6 -0
- package/dist/cjs/src/components/Notifications/Snackbar/useSnackbar.d.ts +4 -4
- package/dist/cjs/src/components/Notifications/Snackbar/useSnackbar.test.d.ts +1 -0
- package/dist/cjs/src/components/Stepper/Stepper.d.ts +0 -1
- package/dist/cjs/src/components/_BaseStyling_/BaseStyling.d.ts +11 -10
- package/dist/cjs/src/hooks/usePosition.cjs.js.map +1 -1
- package/dist/cjs/src/hooks/usePosition.d.ts +1 -1
- package/dist/esm/Button/BaseButton.esm.js.map +1 -1
- package/dist/esm/Button/BaseButton.module.esm.js +1 -1
- package/dist/esm/Button/Button.module.esm.js +1 -1
- package/dist/esm/Button/IconButton.module.esm.js +1 -1
- package/dist/esm/ContextMenu/ContextMenu.esm.js +1 -1
- package/dist/esm/ContextMenu/ContextMenu.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenuItem.module.esm.js +1 -1
- package/dist/esm/ContextMenu/ContextMenuService.esm.js +1 -1
- package/dist/esm/ContextMenu/ContextMenuService.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridActions/DataGridColumnsToggle.module.esm.js +1 -1
- package/dist/esm/Form/Input/Input.module.esm.js +1 -1
- package/dist/esm/Form/Select/Option.esm.js +1 -1
- package/dist/esm/Form/Select/Option.esm.js.map +1 -1
- package/dist/esm/Form/Select/Select.esm.js +1 -1
- package/dist/esm/Form/Select/Select.esm.js.map +1 -1
- package/dist/esm/Form/Select/Select.module.esm.js +1 -1
- package/dist/esm/Form/Select/SelectService.esm.js +1 -1
- package/dist/esm/Form/Select/SelectService.esm.js.map +1 -1
- package/dist/esm/Form/Textarea/Textarea.module.esm.js +1 -1
- package/dist/esm/Icon/Icon.esm.js +1 -1
- package/dist/esm/Icon/Icon.esm.js.map +1 -1
- package/dist/esm/Icon/Icon.module.esm.js +1 -1
- package/dist/esm/Link/Link.esm.js.map +1 -1
- package/dist/esm/Link/Link.module.esm.js +1 -1
- package/dist/esm/Notifications/BaseModal/BaseModal.module.esm.js +1 -1
- package/dist/esm/Notifications/SlideInModal/SlideInModal.module.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.esm.js.map +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.esm.js +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.esm.js.map +1 -1
- package/dist/esm/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.esm.js.map +1 -1
- package/dist/esm/Notifications/Snackbar/interfaces.esm.js +2 -0
- package/dist/esm/Notifications/Snackbar/interfaces.esm.js.map +1 -0
- package/dist/esm/Popover/Popover.esm.js +1 -1
- package/dist/esm/Popover/Popover.esm.js.map +1 -1
- package/dist/esm/Popover/Popover.module.esm.js +1 -1
- package/dist/esm/Stepper/Step.esm.js +1 -1
- package/dist/esm/Stepper/Step.esm.js.map +1 -1
- package/dist/esm/Stepper/Step.module.esm.js +1 -1
- package/dist/esm/Stepper/Stepper.esm.js +1 -1
- package/dist/esm/Stepper/Stepper.esm.js.map +1 -1
- package/dist/esm/Tabs/TabButton.module.esm.js +1 -1
- package/dist/esm/TextEllipsis/TextEllipsis.module.esm.js +1 -1
- package/dist/esm/Tiles/Tile.module.esm.js +1 -1
- package/dist/esm/Tooltip/Tooltip.module.esm.js +1 -1
- package/dist/esm/Wizard/BaseWizardSteps/BaseWizardSteps.module.esm.js +1 -1
- package/dist/esm/_BaseStyling_/BaseStyling.esm.js +1 -1
- package/dist/esm/_BaseStyling_/BaseStyling.esm.js.map +1 -1
- package/dist/esm/src/.scope.d.ts +2 -0
- package/dist/esm/src/components/Button/BaseButton.d.ts +1 -1
- package/dist/esm/src/components/ContextMenu/ContextMenu.d.ts +1 -1
- package/dist/esm/src/components/ContextMenu/ContextMenuService.d.ts +4 -1
- package/dist/esm/src/components/Form/Select/Option.d.ts +1 -0
- package/dist/esm/src/components/Form/Select/Select.d.ts +20 -0
- package/dist/esm/src/components/Form/Select/Select.interfaces.d.ts +3 -1
- package/dist/esm/src/components/Form/Select/Select.test.d.ts +63 -1
- package/dist/esm/src/components/Form/Select/SelectKeyboardNavigation.test.d.ts +1 -0
- package/dist/esm/src/components/Form/Select/SelectService.d.ts +3 -2
- package/dist/esm/src/components/Icon/Icon.d.ts +4 -1
- package/dist/esm/src/components/Link/Link.d.ts +1 -1
- package/dist/esm/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +5 -5
- package/dist/esm/src/components/Notifications/Snackbar/interfaces.d.ts +6 -0
- package/dist/esm/src/components/Notifications/Snackbar/useSnackbar.d.ts +4 -4
- package/dist/esm/src/components/Notifications/Snackbar/useSnackbar.test.d.ts +1 -0
- package/dist/esm/src/components/Stepper/Stepper.d.ts +0 -1
- package/dist/esm/src/components/_BaseStyling_/BaseStyling.d.ts +11 -10
- package/dist/esm/src/hooks/usePosition.d.ts +1 -1
- package/dist/esm/src/hooks/usePosition.esm.js.map +1 -1
- package/package.json +48 -45
- package/src/{hooks/useWrapper.test.ts → .scope.ts} +1 -12
- package/src/components/Button/BaseButton.tsx +1 -1
- package/src/components/Button/Button.module.scss +2 -10
- package/src/components/ContextMenu/ContextMenu.tsx +13 -23
- package/src/components/ContextMenu/ContextMenuService.ts +47 -1
- package/src/components/Form/Select/Option.tsx +3 -1
- package/src/components/Form/Select/Select.interfaces.ts +3 -1
- package/src/components/Form/Select/Select.module.scss +55 -34
- package/src/components/Form/Select/Select.tsx +74 -23
- package/src/components/Form/Select/SelectService.ts +26 -10
- package/src/components/Icon/Icon.module.scss +12 -0
- package/src/components/Icon/Icon.tsx +4 -1
- package/src/components/Link/Link.module.scss +28 -4
- package/src/components/Link/Link.tsx +1 -1
- package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +14 -21
- package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +17 -13
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.tsx +43 -17
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +5 -13
- package/src/components/Notifications/Snackbar/interfaces.ts +15 -0
- package/src/components/Popover/Popover.tsx +19 -2
- package/src/components/Stepper/Step.tsx +2 -1
- package/src/components/Stepper/Stepper.tsx +0 -2
- package/src/components/Tooltip/Tooltip.module.scss +1 -0
- package/src/components/_BaseStyling_/BaseStyling.tsx +24 -22
- package/src/font/icomoon.eot +0 -0
- package/src/font/icomoon.svg +5 -2
- package/src/font/icomoon.ttf +0 -0
- package/src/font/icomoon.woff +0 -0
- package/src/font/selection.json +1 -1
- package/src/hooks/usePosition.ts +1 -1
- package/src/interfaces.ts +2 -2
- package/src/mixins.module.scss +60 -61
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +0 -64
- package/src/components/Button/BaseButton.test.tsx +0 -133
- package/src/components/Button/Button.test.tsx +0 -138
- package/src/components/Button/IconButton.test.tsx +0 -122
- package/src/components/ContextMenu/ContextMenu.test.tsx +0 -358
- package/src/components/DataGrid/DataGrid.test.tsx +0 -437
- package/src/components/DataGrid/DataGridActions/DataGridActions.test.tsx +0 -204
- package/src/components/DataGrid/DataGridActions/DataGridColumnsToggle.test.tsx +0 -99
- package/src/components/DataGrid/DataGridBody/DataGridBody.test.tsx +0 -140
- package/src/components/DataGrid/DataGridBody/DataGridCell.test.tsx +0 -90
- package/src/components/DataGrid/DataGridBody/DataGridRow.test.tsx +0 -117
- package/src/components/DataGrid/DataGridHeader/DataGridHeader.test.tsx +0 -276
- package/src/components/DataGrid/DataGridHeader/DataGridHeaderCell.test.tsx +0 -144
- package/src/components/Form/Checkbox/Checkbox.test.tsx +0 -308
- package/src/components/Form/Fieldset/Fieldset.test.tsx +0 -127
- package/src/components/Form/FileUpload/FileItem/FileItem.test.tsx +0 -103
- package/src/components/Form/FileUpload/FileUpload.test.tsx +0 -374
- package/src/components/Form/Form.test.tsx +0 -63
- package/src/components/Form/FormControl/FormControl.test.tsx +0 -98
- package/src/components/Form/FormGroup/FormGroup.test.tsx +0 -127
- package/src/components/Form/FormHelperText/FormHelperText.test.tsx +0 -84
- package/src/components/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +0 -94
- package/src/components/Form/Input/Input.test.tsx +0 -267
- package/src/components/Form/Label/Label.test.tsx +0 -68
- package/src/components/Form/Radio/Radio.test.tsx +0 -130
- package/src/components/Form/Select/Option.test.tsx +0 -57
- package/src/components/Form/Select/Select.test.tsx +0 -564
- package/src/components/Form/Textarea/Textarea.test.tsx +0 -124
- package/src/components/Form/Toggle/Toggle.test.tsx +0 -200
- package/src/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +0 -141
- package/src/components/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +0 -211
- package/src/components/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +0 -117
- package/src/components/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +0 -186
- package/src/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +0 -173
- package/src/components/Form/Wrapper/Wrapper/Wrapper.test.tsx +0 -59
- package/src/components/Icon/Icon.test.tsx +0 -83
- package/src/components/Link/Link.test.tsx +0 -197
- package/src/components/Notifications/Banner/Banner.test.tsx +0 -84
- package/src/components/Notifications/BaseModal/BaseModal.test.tsx +0 -194
- package/src/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +0 -74
- package/src/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.test.tsx +0 -71
- package/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.test.tsx +0 -74
- package/src/components/Notifications/Dialog/Dialog.test.tsx +0 -118
- package/src/components/Notifications/Dialog/DialogActions/DialogActions.test.tsx +0 -61
- package/src/components/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +0 -87
- package/src/components/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +0 -111
- package/src/components/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +0 -175
- package/src/components/Notifications/Modal/Modal.test.tsx +0 -18
- package/src/components/Notifications/NotificationProvider/NotificationContext.test.tsx +0 -449
- package/src/components/Notifications/SlideInModal/SlideInModal.test.tsx +0 -90
- package/src/components/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.test.tsx +0 -53
- package/src/components/Notifications/Snackbar/SnackbarItem/SnackbarItem.test.tsx +0 -63
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +0 -215
- package/src/components/Pagination/Pagination.test.tsx +0 -183
- package/src/components/Popover/Popover.test.tsx +0 -103
- package/src/components/ProgressBar/ProgressBar.test.tsx +0 -91
- package/src/components/Skeleton/Skeleton.test.tsx +0 -112
- package/src/components/StatusIndicator/StatusIndicator.test.tsx +0 -143
- package/src/components/Stepper/Stepper.test.tsx +0 -83
- package/src/components/Tabs/Tab.test.tsx +0 -49
- package/src/components/Tabs/TabButton.test.tsx +0 -65
- package/src/components/Tabs/Tabs.test.tsx +0 -291
- package/src/components/Tag/Tag.test.tsx +0 -89
- package/src/components/TextEllipsis/TextEllipsis.test.tsx +0 -96
- package/src/components/Tiles/Tile.test.tsx +0 -183
- package/src/components/Tiles/Tiles.test.tsx +0 -162
- package/src/components/Tooltip/Tooltip.test.tsx +0 -390
- package/src/components/Typography/Typography.test.tsx +0 -177
- package/src/components/Wizard/BaseWizardSteps/BaseWizardSteps.test.tsx +0 -90
- package/src/components/Wizard/Wizard.test.tsx +0 -218
- package/src/components/Wizard/WizardActions/WizardActions.test.tsx +0 -187
- package/src/components/Wizard/WizardSteps/WizardSteps.test.tsx +0 -125
- package/src/components/_BaseStyling_/BaseStyling.test.tsx +0 -55
- package/src/hooks/useAnimation.test.tsx +0 -65
- package/src/hooks/useBodyClick.test.tsx +0 -55
- package/src/hooks/useDebouncedCallback.test.ts +0 -150
- package/src/hooks/useDetermineStatusIcon.test.ts +0 -28
- package/src/hooks/useFormSelector.test.ts +0 -56
- package/src/hooks/usePosition.test.tsx +0 -510
- package/src/hooks/useRepeater.test.tsx +0 -156
- package/src/hooks/useScroll.test.tsx +0 -36
- package/src/hooks/useSpacing.test.ts +0 -86
- package/src/hooks/useUploadFile.test.ts +0 -211
- package/src/util/helper.test.tsx +0 -403
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 OneWelcome B.V.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import React, { useState } from "react";
|
|
18
|
-
import { Wizard, Props } from "./Wizard";
|
|
19
|
-
import {
|
|
20
|
-
getAllByRole,
|
|
21
|
-
getByText,
|
|
22
|
-
render,
|
|
23
|
-
getByTestId,
|
|
24
|
-
queryByRole,
|
|
25
|
-
findByText
|
|
26
|
-
} from "@testing-library/react";
|
|
27
|
-
import { WizardActions, Props as WizardActionProps } from "./WizardActions/WizardActions";
|
|
28
|
-
import { WizardSteps } from "./WizardSteps/WizardSteps";
|
|
29
|
-
import userEvent from "@testing-library/user-event";
|
|
30
|
-
|
|
31
|
-
type initWizardPropsType = Omit<Omit<Props, "onStepChange">, "children">;
|
|
32
|
-
|
|
33
|
-
const initWizardParams: initWizardPropsType = {
|
|
34
|
-
steps: [
|
|
35
|
-
{
|
|
36
|
-
label: "Step 1"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
label: "Step 2"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
label: "Step 3",
|
|
43
|
-
disabled: true
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
label: "Step 4"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
initialStepNo: 0,
|
|
50
|
-
mode: "add"
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const initWizardStepsProps = {
|
|
54
|
-
onStepClick: jest.fn()
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const initWizardActionsProps: WizardActionProps = {
|
|
58
|
-
actions: {
|
|
59
|
-
next: {
|
|
60
|
-
label: "Next",
|
|
61
|
-
onClick: jest.fn()
|
|
62
|
-
},
|
|
63
|
-
previous: {
|
|
64
|
-
label: "Previous",
|
|
65
|
-
onClick: jest.fn()
|
|
66
|
-
},
|
|
67
|
-
saveAndClose: {
|
|
68
|
-
label: "Save and close",
|
|
69
|
-
onClick: jest.fn()
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const renderWizard = (wizardProps?: initWizardPropsType) => {
|
|
75
|
-
const customWizardProps = wizardProps ? wizardProps : initWizardParams;
|
|
76
|
-
|
|
77
|
-
const Content = () => {
|
|
78
|
-
const [step, setStep] = useState(customWizardProps.initialStepNo || 0);
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Wizard {...customWizardProps} onStepChange={(stepNo: number) => setStep(stepNo)}>
|
|
82
|
-
<WizardSteps data-testid="wizard-steps" {...initWizardStepsProps} />
|
|
83
|
-
<div data-testid="wizard-content">Step {step + 1}</div>
|
|
84
|
-
<div data-testid="wizard-actions">
|
|
85
|
-
<WizardActions {...initWizardActionsProps} />
|
|
86
|
-
</div>
|
|
87
|
-
</Wizard>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return render(<Content />);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const getWizardContent = (container: HTMLElement) => getByTestId(container, "wizard-content");
|
|
95
|
-
|
|
96
|
-
const getStepButtons = (container: HTMLElement) =>
|
|
97
|
-
getAllByRole(getByTestId(container, "wizard-steps"), "button");
|
|
98
|
-
|
|
99
|
-
const getActionsButtons = (container: HTMLElement) => {
|
|
100
|
-
const actionsContainer = getByTestId(container, "wizard-actions");
|
|
101
|
-
const next = queryByRole(actionsContainer, "button", {
|
|
102
|
-
name: initWizardActionsProps.actions.next.label
|
|
103
|
-
});
|
|
104
|
-
const prev = queryByRole(actionsContainer, "button", {
|
|
105
|
-
name: initWizardActionsProps.actions.previous.label
|
|
106
|
-
});
|
|
107
|
-
const save = queryByRole(actionsContainer, "button", {
|
|
108
|
-
name: initWizardActionsProps.actions.saveAndClose.label
|
|
109
|
-
});
|
|
110
|
-
return { next, prev, save };
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
describe("Wizard", () => {
|
|
114
|
-
it("renders without crashing", () => {
|
|
115
|
-
const { container } = renderWizard();
|
|
116
|
-
const { prev, next, save } = getActionsButtons(container);
|
|
117
|
-
const stepButtons = getStepButtons(container);
|
|
118
|
-
const wizardContent = getWizardContent(container);
|
|
119
|
-
|
|
120
|
-
expect(stepButtons).toHaveLength(4);
|
|
121
|
-
expect(getByText(stepButtons[0], "1")).toBeDefined();
|
|
122
|
-
expect(getByText(stepButtons[1], "2")).toBeDefined();
|
|
123
|
-
expect(getByText(stepButtons[2], "3")).toBeDefined();
|
|
124
|
-
expect(getByText(stepButtons[3], "4")).toBeDefined();
|
|
125
|
-
expect(wizardContent).toHaveTextContent("Step 1");
|
|
126
|
-
expect(next).toBeDefined();
|
|
127
|
-
expect(prev).toBeNull();
|
|
128
|
-
expect(save).toBeNull();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("should be able to click over whole wizard via action buttons", async () => {
|
|
132
|
-
const { container } = renderWizard();
|
|
133
|
-
const { next } = getActionsButtons(container);
|
|
134
|
-
const wizardContent = getWizardContent(container);
|
|
135
|
-
(
|
|
136
|
-
initWizardActionsProps.actions.next.onClick as jest.MockedFunction<
|
|
137
|
-
typeof initWizardActionsProps.actions.next.onClick
|
|
138
|
-
>
|
|
139
|
-
).mockReturnValue(true);
|
|
140
|
-
|
|
141
|
-
await findByText(wizardContent, "Step 1");
|
|
142
|
-
next && (await userEvent.click(next));
|
|
143
|
-
await findByText(wizardContent, "Step 2");
|
|
144
|
-
next && (await userEvent.click(next));
|
|
145
|
-
await findByText(wizardContent, "Step 4");
|
|
146
|
-
const { save, prev } = getActionsButtons(container);
|
|
147
|
-
save && (await userEvent.click(save));
|
|
148
|
-
expect(initWizardActionsProps.actions.saveAndClose.onClick).toBeCalledWith(3);
|
|
149
|
-
prev && (await userEvent.click(prev));
|
|
150
|
-
await findByText(wizardContent, "Step 2");
|
|
151
|
-
prev && (await userEvent.click(prev));
|
|
152
|
-
await findByText(wizardContent, "Step 1");
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("should not be able to click over whole wizard via steps buttons in add mode", async () => {
|
|
156
|
-
const { container } = renderWizard();
|
|
157
|
-
const { next } = getActionsButtons(container);
|
|
158
|
-
const stepsButtons = getStepButtons(container);
|
|
159
|
-
const wizardContent = getWizardContent(container);
|
|
160
|
-
(
|
|
161
|
-
initWizardActionsProps.actions.next.onClick as jest.MockedFunction<
|
|
162
|
-
typeof initWizardActionsProps.actions.next.onClick
|
|
163
|
-
>
|
|
164
|
-
).mockReturnValue(true);
|
|
165
|
-
(
|
|
166
|
-
initWizardStepsProps.onStepClick as jest.MockedFunction<
|
|
167
|
-
typeof initWizardStepsProps.onStepClick
|
|
168
|
-
>
|
|
169
|
-
).mockReturnValue(true);
|
|
170
|
-
|
|
171
|
-
await userEvent.click(stepsButtons[1]);
|
|
172
|
-
await userEvent.click(stepsButtons[2]);
|
|
173
|
-
await userEvent.click(stepsButtons[3]);
|
|
174
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(0);
|
|
175
|
-
await findByText(wizardContent, "Step 1");
|
|
176
|
-
|
|
177
|
-
next && (await userEvent.click(next));
|
|
178
|
-
next && (await userEvent.click(next));
|
|
179
|
-
await findByText(wizardContent, "Step 4");
|
|
180
|
-
await userEvent.click(stepsButtons[2]);
|
|
181
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(0);
|
|
182
|
-
await userEvent.click(stepsButtons[1]);
|
|
183
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(1);
|
|
184
|
-
await findByText(wizardContent, "Step 2");
|
|
185
|
-
await userEvent.click(stepsButtons[0]);
|
|
186
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(2);
|
|
187
|
-
await findByText(wizardContent, "Step 1");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("should be able to click over whole wizard via steps buttons in edit mode", async () => {
|
|
191
|
-
const { container } = renderWizard({ ...initWizardParams, mode: "edit" });
|
|
192
|
-
const stepsButtons = getStepButtons(container);
|
|
193
|
-
const wizardContent = getWizardContent(container);
|
|
194
|
-
(
|
|
195
|
-
initWizardStepsProps.onStepClick as jest.MockedFunction<
|
|
196
|
-
typeof initWizardStepsProps.onStepClick
|
|
197
|
-
>
|
|
198
|
-
).mockReturnValue(true);
|
|
199
|
-
|
|
200
|
-
await userEvent.click(stepsButtons[1]);
|
|
201
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(1);
|
|
202
|
-
await findByText(wizardContent, "Step 2");
|
|
203
|
-
await userEvent.click(stepsButtons[2]);
|
|
204
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(1);
|
|
205
|
-
await userEvent.click(stepsButtons[3]);
|
|
206
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(2);
|
|
207
|
-
await findByText(wizardContent, "Step 4");
|
|
208
|
-
|
|
209
|
-
await userEvent.click(stepsButtons[2]);
|
|
210
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(2);
|
|
211
|
-
await userEvent.click(stepsButtons[1]);
|
|
212
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(3);
|
|
213
|
-
await findByText(wizardContent, "Step 2");
|
|
214
|
-
await userEvent.click(stepsButtons[0]);
|
|
215
|
-
expect(initWizardStepsProps.onStepClick).toBeCalledTimes(4);
|
|
216
|
-
await findByText(wizardContent, "Step 1");
|
|
217
|
-
});
|
|
218
|
-
});
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 OneWelcome B.V.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import React, { useReducer } from "react";
|
|
18
|
-
import { WizardActions, Props } from "./WizardActions";
|
|
19
|
-
import { queryByRole, render } from "@testing-library/react";
|
|
20
|
-
import { WizardStateContext, Props as ProviderProps } from "../WizardStateProvider";
|
|
21
|
-
import { WizardStateType, reducer, changeCurrentStepNo } from "../wizardStateReducer";
|
|
22
|
-
import userEvent from "@testing-library/user-event";
|
|
23
|
-
|
|
24
|
-
const initWizardState: WizardStateType = {
|
|
25
|
-
steps: [
|
|
26
|
-
{
|
|
27
|
-
label: "Step 1"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: "Step 2"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: "Step 3",
|
|
34
|
-
disabled: true
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
label: "Step 4"
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
currentStepNo: 0,
|
|
41
|
-
mode: "add"
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const initParams: Props = {
|
|
45
|
-
actions: {
|
|
46
|
-
next: {
|
|
47
|
-
label: "Next",
|
|
48
|
-
onClick: jest.fn()
|
|
49
|
-
},
|
|
50
|
-
previous: {
|
|
51
|
-
label: "Previous",
|
|
52
|
-
onClick: jest.fn()
|
|
53
|
-
},
|
|
54
|
-
saveAndClose: {
|
|
55
|
-
label: "Save and close",
|
|
56
|
-
onClick: jest.fn()
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const renderWizardActions = (initReducerState?: WizardStateType, props?: Props) => {
|
|
62
|
-
const wizardState = initReducerState ? initReducerState : initWizardState;
|
|
63
|
-
const actionsProps = props ? props : initParams;
|
|
64
|
-
const dispatch = jest.fn();
|
|
65
|
-
|
|
66
|
-
const Provider = ({ children }: ProviderProps) => {
|
|
67
|
-
const [state] = useReducer(reducer, wizardState);
|
|
68
|
-
return (
|
|
69
|
-
<WizardStateContext.Provider value={{ state, dispatch }}>
|
|
70
|
-
{children}
|
|
71
|
-
</WizardStateContext.Provider>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const renderObj = render(
|
|
76
|
-
<Provider initialState={initWizardState}>
|
|
77
|
-
<WizardActions {...actionsProps} />
|
|
78
|
-
</Provider>
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
...renderObj,
|
|
83
|
-
dispatch
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const getActionsButtons = (container: HTMLElement) => {
|
|
88
|
-
const next = queryByRole(container, "button", { name: initParams.actions.next.label });
|
|
89
|
-
const prev = queryByRole(container, "button", { name: initParams.actions.previous.label });
|
|
90
|
-
const save = queryByRole(container, "button", { name: initParams.actions.saveAndClose.label });
|
|
91
|
-
return { next, prev, save };
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
describe("WizardActions", () => {
|
|
95
|
-
it("renders without crashing", async () => {
|
|
96
|
-
const { container, dispatch } = renderWizardActions();
|
|
97
|
-
const { prev, next, save } = getActionsButtons(container);
|
|
98
|
-
(
|
|
99
|
-
initParams.actions.next.onClick as jest.MockedFunction<typeof initParams.actions.next.onClick>
|
|
100
|
-
).mockReturnValueOnce(true);
|
|
101
|
-
|
|
102
|
-
expect(next).toBeDefined();
|
|
103
|
-
next && (await userEvent.click(next));
|
|
104
|
-
expect(prev).toBeNull();
|
|
105
|
-
expect(save).toBeNull();
|
|
106
|
-
|
|
107
|
-
expect(initParams.actions.next.onClick).toHaveBeenCalledWith(0);
|
|
108
|
-
expect(dispatch).toBeCalledWith(changeCurrentStepNo(1));
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("should allow going prev and forward when there are prev step and next step (next step is disabled but next one can be used)", async () => {
|
|
112
|
-
const { container, dispatch } = renderWizardActions({ ...initWizardState, currentStepNo: 1 });
|
|
113
|
-
const { prev, next, save } = getActionsButtons(container);
|
|
114
|
-
(
|
|
115
|
-
initParams.actions.next.onClick as jest.MockedFunction<typeof initParams.actions.next.onClick>
|
|
116
|
-
).mockReturnValueOnce(true);
|
|
117
|
-
|
|
118
|
-
expect(prev).toBeDefined();
|
|
119
|
-
prev && (await userEvent.click(prev));
|
|
120
|
-
expect(initParams.actions.previous.onClick).toBeCalled();
|
|
121
|
-
expect(dispatch).toBeCalledWith(changeCurrentStepNo(0));
|
|
122
|
-
|
|
123
|
-
expect(next).toBeDefined();
|
|
124
|
-
next && (await userEvent.click(next));
|
|
125
|
-
expect(initParams.actions.next.onClick).toHaveBeenCalledWith(1);
|
|
126
|
-
expect(dispatch).toBeCalledWith(changeCurrentStepNo(3));
|
|
127
|
-
|
|
128
|
-
expect(save).toBeNull();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("should render save button but not next button when current step is the last step", async () => {
|
|
132
|
-
const { container } = renderWizardActions({ ...initWizardState, currentStepNo: 3 });
|
|
133
|
-
const { prev, next, save } = getActionsButtons(container);
|
|
134
|
-
|
|
135
|
-
expect(prev).toBeDefined();
|
|
136
|
-
expect(next).toBeNull();
|
|
137
|
-
expect(save).toBeDefined();
|
|
138
|
-
|
|
139
|
-
save && (await userEvent.click(save));
|
|
140
|
-
expect(initParams.actions.saveAndClose.onClick).toHaveBeenCalledWith(3);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("should show save and close when next steps are disabled", async () => {
|
|
144
|
-
const steps = [
|
|
145
|
-
initWizardState.steps[0],
|
|
146
|
-
{ ...initWizardState.steps[1], disabled: true },
|
|
147
|
-
{ ...initWizardState.steps[2], disabled: true }
|
|
148
|
-
];
|
|
149
|
-
const { container } = renderWizardActions({
|
|
150
|
-
...initWizardState,
|
|
151
|
-
steps: steps,
|
|
152
|
-
currentStepNo: 0
|
|
153
|
-
});
|
|
154
|
-
const { prev, next, save } = getActionsButtons(container);
|
|
155
|
-
|
|
156
|
-
expect(prev).toBeNull();
|
|
157
|
-
expect(next).toBeNull();
|
|
158
|
-
expect(save).toBeDefined();
|
|
159
|
-
|
|
160
|
-
save && (await userEvent.click(save));
|
|
161
|
-
expect(initParams.actions.saveAndClose.onClick).toHaveBeenCalledWith(0);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("should show save button on middle step when mode is `edit`", async () => {
|
|
165
|
-
const { container } = renderWizardActions({ ...initWizardState, mode: "edit" });
|
|
166
|
-
const { prev, next, save } = getActionsButtons(container);
|
|
167
|
-
|
|
168
|
-
expect(prev).toBeNull();
|
|
169
|
-
expect(next).toBeDefined();
|
|
170
|
-
expect(save).toBeDefined();
|
|
171
|
-
|
|
172
|
-
save && (await userEvent.click(save));
|
|
173
|
-
expect(initParams.actions.saveAndClose.onClick).toHaveBeenCalledWith(0);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("should not allow going forward when dev returns false on onNext callback", async () => {
|
|
177
|
-
const { container, dispatch } = renderWizardActions();
|
|
178
|
-
const { next } = getActionsButtons(container);
|
|
179
|
-
(
|
|
180
|
-
initParams.actions.next.onClick as jest.MockedFunction<typeof initParams.actions.next.onClick>
|
|
181
|
-
).mockReturnValueOnce(false);
|
|
182
|
-
|
|
183
|
-
next && (await userEvent.click(next));
|
|
184
|
-
expect(initParams.actions.next.onClick).toHaveBeenCalledWith(0);
|
|
185
|
-
expect(dispatch).not.toBeCalled();
|
|
186
|
-
});
|
|
187
|
-
});
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 OneWelcome B.V.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import React, { useReducer } from "react";
|
|
18
|
-
import { WizardSteps, Props } from "./WizardSteps";
|
|
19
|
-
import { getAllByRole, getByText, render } from "@testing-library/react";
|
|
20
|
-
import { WizardStateContext, Props as ProviderProps } from "../WizardStateProvider";
|
|
21
|
-
import { WizardStateType, reducer, changeCurrentStepNo } from "../wizardStateReducer";
|
|
22
|
-
import userEvent from "@testing-library/user-event";
|
|
23
|
-
|
|
24
|
-
const initWizardState: WizardStateType = {
|
|
25
|
-
steps: [
|
|
26
|
-
{
|
|
27
|
-
label: "Step 1"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: "Step 2"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: "Step 3",
|
|
34
|
-
disabled: true
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
label: "Step 4"
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
currentStepNo: 1,
|
|
41
|
-
mode: "add"
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const initParams: Props = {
|
|
45
|
-
onStepClick: jest.fn()
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const renderWizardSteps = (initReducerState?: WizardStateType) => {
|
|
49
|
-
const wizardState = initReducerState ? initReducerState : initWizardState;
|
|
50
|
-
const dispatch = jest.fn();
|
|
51
|
-
|
|
52
|
-
const Provider = ({ children }: ProviderProps) => {
|
|
53
|
-
const [state] = useReducer(reducer, wizardState);
|
|
54
|
-
return (
|
|
55
|
-
<WizardStateContext.Provider value={{ state, dispatch }}>
|
|
56
|
-
{children}
|
|
57
|
-
</WizardStateContext.Provider>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const renderObj = render(
|
|
62
|
-
<Provider initialState={initWizardState}>
|
|
63
|
-
<WizardSteps {...initParams} />
|
|
64
|
-
</Provider>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
...renderObj,
|
|
69
|
-
dispatch
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const getStepButtons = (container: HTMLElement) => getAllByRole(container, "button");
|
|
74
|
-
|
|
75
|
-
describe("WizardSteps", () => {
|
|
76
|
-
it("renders without crashing", async () => {
|
|
77
|
-
const { container, dispatch } = renderWizardSteps();
|
|
78
|
-
const buttons = getStepButtons(container);
|
|
79
|
-
(
|
|
80
|
-
initParams.onStepClick as jest.MockedFunction<typeof initParams.onStepClick>
|
|
81
|
-
).mockReturnValueOnce(true);
|
|
82
|
-
|
|
83
|
-
expect(buttons).toHaveLength(4);
|
|
84
|
-
await userEvent.click(buttons[0]);
|
|
85
|
-
expect(initParams.onStepClick).toHaveBeenCalledWith(initWizardState.currentStepNo, 0);
|
|
86
|
-
expect(dispatch).toBeCalledWith(changeCurrentStepNo(0));
|
|
87
|
-
expect(buttons[0].querySelector(".checkmark")).toBeDefined();
|
|
88
|
-
expect(getByText(buttons[1], "2")).toBeDefined();
|
|
89
|
-
expect(getByText(buttons[2], "3")).toBeDefined();
|
|
90
|
-
expect(getByText(buttons[3], "4")).toBeDefined();
|
|
91
|
-
|
|
92
|
-
await userEvent.click(buttons[1]);
|
|
93
|
-
await userEvent.click(buttons[2]);
|
|
94
|
-
await userEvent.click(buttons[3]);
|
|
95
|
-
expect(initParams.onStepClick).toHaveBeenCalledTimes(1);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should allow to click on future and prev steps but not on current and disabled steps when mode is set to `edit`", async () => {
|
|
99
|
-
const { container, dispatch } = renderWizardSteps({ ...initWizardState, mode: "edit" });
|
|
100
|
-
const buttons = getStepButtons(container);
|
|
101
|
-
(
|
|
102
|
-
initParams.onStepClick as jest.MockedFunction<typeof initParams.onStepClick>
|
|
103
|
-
).mockReturnValueOnce(true);
|
|
104
|
-
|
|
105
|
-
await userEvent.click(buttons[3]);
|
|
106
|
-
expect(initParams.onStepClick).toHaveBeenCalledWith(initWizardState.currentStepNo, 3);
|
|
107
|
-
expect(dispatch).toBeCalledWith(changeCurrentStepNo(3));
|
|
108
|
-
|
|
109
|
-
await userEvent.click(buttons[1]);
|
|
110
|
-
await userEvent.click(buttons[2]);
|
|
111
|
-
expect(initParams.onStepClick).toHaveBeenCalledTimes(1);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("should do not change step when `onStepClick` callback returns false", async () => {
|
|
115
|
-
const { container, dispatch } = renderWizardSteps({ ...initWizardState, mode: "edit" });
|
|
116
|
-
const buttons = getStepButtons(container);
|
|
117
|
-
(
|
|
118
|
-
initParams.onStepClick as jest.MockedFunction<typeof initParams.onStepClick>
|
|
119
|
-
).mockReturnValueOnce(false);
|
|
120
|
-
|
|
121
|
-
await userEvent.click(buttons[3]);
|
|
122
|
-
expect(initParams.onStepClick).toHaveBeenCalledWith(initWizardState.currentStepNo, 3);
|
|
123
|
-
expect(dispatch).not.toBeCalled();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 OneWelcome B.V.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import React, { Fragment } from "react";
|
|
18
|
-
import { BaseStyling } from "./BaseStyling";
|
|
19
|
-
import { Button } from "../Button/Button";
|
|
20
|
-
import { render } from "@testing-library/react";
|
|
21
|
-
|
|
22
|
-
describe("BaseStyling should render", () => {
|
|
23
|
-
it("renders without crashing", async () => {
|
|
24
|
-
const { container, findByTestId } = render(
|
|
25
|
-
<Fragment>
|
|
26
|
-
<BaseStyling>
|
|
27
|
-
<Button data-testid="button">Test</Button>
|
|
28
|
-
</BaseStyling>
|
|
29
|
-
</Fragment>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const button = await findByTestId("button");
|
|
33
|
-
expect(button).toHaveStyle({ backgroundColor: "rgb(158, 0, 107);" });
|
|
34
|
-
expect(container.querySelector("#child")).toBeDefined();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("Should override default color", () => {
|
|
39
|
-
it("overrides primary color", async () => {
|
|
40
|
-
const { findByTestId } = render(
|
|
41
|
-
<Fragment>
|
|
42
|
-
<BaseStyling
|
|
43
|
-
properties={{
|
|
44
|
-
colorPrimary: "rgb(255, 255, 255);"
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
<Button data-testid="button">Test</Button>
|
|
48
|
-
</BaseStyling>
|
|
49
|
-
</Fragment>
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const button = await findByTestId("button");
|
|
53
|
-
expect(button).toHaveStyle({ backgroundColor: "rgb(255, 255, 255);" });
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2022 OneWelcome B.V.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import React, { Fragment } from "react";
|
|
18
|
-
import { render, fireEvent } from "@testing-library/react";
|
|
19
|
-
import userEvent from "@testing-library/user-event";
|
|
20
|
-
import { useAnimation } from "./useAnimation";
|
|
21
|
-
import { act } from "react-dom/test-utils";
|
|
22
|
-
|
|
23
|
-
describe("useAnimation", () => {
|
|
24
|
-
it("should execute", async () => {
|
|
25
|
-
const callback = jest.fn();
|
|
26
|
-
|
|
27
|
-
const Component = () => {
|
|
28
|
-
const { ref, animationStarted, startAnimation } = useAnimation<HTMLDivElement>(callback);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Fragment>
|
|
32
|
-
<button data-testid="button" onClick={() => startAnimation()}>
|
|
33
|
-
start animation
|
|
34
|
-
</button>
|
|
35
|
-
<div
|
|
36
|
-
data-testid="animated-div"
|
|
37
|
-
ref={ref}
|
|
38
|
-
className={animationStarted ? "animation-started" : ""}
|
|
39
|
-
>
|
|
40
|
-
animated div
|
|
41
|
-
</div>
|
|
42
|
-
</Fragment>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const { getByTestId } = render(<Component />);
|
|
47
|
-
|
|
48
|
-
const animatedDiv = getByTestId("animated-div");
|
|
49
|
-
const startButton = getByTestId("button");
|
|
50
|
-
|
|
51
|
-
expect(animatedDiv).not.toHaveClass("animation-started");
|
|
52
|
-
expect(callback).not.toBeCalled();
|
|
53
|
-
await userEvent.click(startButton);
|
|
54
|
-
|
|
55
|
-
expect(animatedDiv).toHaveClass("animation-started");
|
|
56
|
-
expect(callback).not.toBeCalled();
|
|
57
|
-
|
|
58
|
-
act(() => {
|
|
59
|
-
fireEvent.animationEnd(animatedDiv);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
expect(animatedDiv).toHaveClass("animation-started");
|
|
63
|
-
expect(callback).toBeCalled();
|
|
64
|
-
});
|
|
65
|
-
});
|