@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,390 +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 from "react";
|
|
18
|
-
import { Tooltip, Props } from "./Tooltip";
|
|
19
|
-
import { render, waitFor } from "@testing-library/react";
|
|
20
|
-
import userEvent from "@testing-library/user-event";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {
|
|
23
|
-
children: "This is a test message",
|
|
24
|
-
label: "Label",
|
|
25
|
-
title: "Title",
|
|
26
|
-
position: "start",
|
|
27
|
-
location: "left"
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const createTooltip = async (params?: (defaultParams: Props) => Props) => {
|
|
31
|
-
let parameters: Props = defaultParams;
|
|
32
|
-
if (params) {
|
|
33
|
-
parameters = params(defaultParams);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const queries = render(<Tooltip {...parameters} data-testid="tooltip" />);
|
|
37
|
-
const tooltip = queries.getByTestId("tooltip");
|
|
38
|
-
const icon = tooltip.querySelector(".icon")!;
|
|
39
|
-
const tooltipHoverDiv = document.querySelector(".tooltip");
|
|
40
|
-
|
|
41
|
-
if (tooltip) {
|
|
42
|
-
icon.getBoundingClientRect = () => ({
|
|
43
|
-
x: 500,
|
|
44
|
-
y: 500,
|
|
45
|
-
width: 10,
|
|
46
|
-
height: 10,
|
|
47
|
-
top: 500,
|
|
48
|
-
left: 500,
|
|
49
|
-
right: 510,
|
|
50
|
-
bottom: 510,
|
|
51
|
-
toJSON: () => jest.fn()
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
Object.defineProperty(tooltipHoverDiv, "offsetHeight", { configurable: true, value: 50 });
|
|
56
|
-
Object.defineProperty(tooltipHoverDiv, "offsetWidth", { configurable: true, value: 200 });
|
|
57
|
-
|
|
58
|
-
const hoverIcon = async () => {
|
|
59
|
-
await userEvent.hover(icon);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
...queries,
|
|
64
|
-
tooltip,
|
|
65
|
-
tooltipHoverDiv,
|
|
66
|
-
hoverIcon
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
describe("Tooltip", () => {
|
|
71
|
-
describe("Rendering", () => {
|
|
72
|
-
beforeEach(() => {
|
|
73
|
-
Object.defineProperty(window, "innerHeight", {
|
|
74
|
-
configurable: true,
|
|
75
|
-
value: 1000
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(window, "innerWidth", {
|
|
78
|
-
configurable: true,
|
|
79
|
-
value: 1000
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should render the tooltip with the default parameters", async () => {
|
|
84
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(defaultParams => ({
|
|
85
|
-
...defaultParams,
|
|
86
|
-
location: undefined,
|
|
87
|
-
position: undefined
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
await hoverIcon();
|
|
91
|
-
|
|
92
|
-
expect(tooltip).toBeInTheDocument();
|
|
93
|
-
await waitFor(() =>
|
|
94
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
95
|
-
left: "522px",
|
|
96
|
-
top: "480px"
|
|
97
|
-
})
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should render the tooltip with a custom location to the right and position end", async () => {
|
|
102
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
103
|
-
...p,
|
|
104
|
-
location: "right",
|
|
105
|
-
position: "end"
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
await hoverIcon();
|
|
109
|
-
|
|
110
|
-
expect(tooltip).toBeInTheDocument();
|
|
111
|
-
await waitFor(() =>
|
|
112
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
113
|
-
top: "488px",
|
|
114
|
-
left: "522px"
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("should render the tooltip with a custom location to the right and position start", async () => {
|
|
120
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
121
|
-
...p,
|
|
122
|
-
location: "right",
|
|
123
|
-
position: "start"
|
|
124
|
-
}));
|
|
125
|
-
|
|
126
|
-
await hoverIcon();
|
|
127
|
-
|
|
128
|
-
expect(tooltip).toBeInTheDocument();
|
|
129
|
-
await waitFor(() =>
|
|
130
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
131
|
-
left: "522px",
|
|
132
|
-
bottom: "478px"
|
|
133
|
-
})
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("should render the tooltip with a custom location to the right and position center", async () => {
|
|
138
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
139
|
-
...p,
|
|
140
|
-
location: "right",
|
|
141
|
-
position: "center"
|
|
142
|
-
}));
|
|
143
|
-
|
|
144
|
-
await hoverIcon();
|
|
145
|
-
|
|
146
|
-
expect(tooltip).toBeInTheDocument();
|
|
147
|
-
await waitFor(() =>
|
|
148
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
149
|
-
left: "522px",
|
|
150
|
-
top: "480px"
|
|
151
|
-
})
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("should render the tooltip with a custom location to the left and position end", async () => {
|
|
156
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
157
|
-
...p,
|
|
158
|
-
location: "left",
|
|
159
|
-
position: "end"
|
|
160
|
-
}));
|
|
161
|
-
|
|
162
|
-
await hoverIcon();
|
|
163
|
-
|
|
164
|
-
expect(tooltip).toBeInTheDocument();
|
|
165
|
-
await waitFor(() =>
|
|
166
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
167
|
-
right: "512px",
|
|
168
|
-
top: "488px"
|
|
169
|
-
})
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it("should render the tooltip with a custom location to the left and position start", async () => {
|
|
174
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
175
|
-
...p,
|
|
176
|
-
location: "left",
|
|
177
|
-
position: "start"
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
await hoverIcon();
|
|
181
|
-
|
|
182
|
-
expect(tooltip).toBeInTheDocument();
|
|
183
|
-
await waitFor(() =>
|
|
184
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
185
|
-
right: "512px",
|
|
186
|
-
bottom: "478px"
|
|
187
|
-
})
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("should render the tooltip with a custom location to the left and position center", async () => {
|
|
192
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
193
|
-
...p,
|
|
194
|
-
location: "left",
|
|
195
|
-
position: "center"
|
|
196
|
-
}));
|
|
197
|
-
|
|
198
|
-
await hoverIcon();
|
|
199
|
-
|
|
200
|
-
expect(tooltip).toBeInTheDocument();
|
|
201
|
-
await waitFor(() =>
|
|
202
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
203
|
-
right: "512px",
|
|
204
|
-
top: "480px"
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("should render the tooltip with a custom location to the top and position end", async () => {
|
|
210
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
211
|
-
...p,
|
|
212
|
-
location: "top",
|
|
213
|
-
position: "end"
|
|
214
|
-
}));
|
|
215
|
-
|
|
216
|
-
await hoverIcon();
|
|
217
|
-
|
|
218
|
-
expect(tooltip).toBeInTheDocument();
|
|
219
|
-
await waitFor(() =>
|
|
220
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
221
|
-
left: "488px",
|
|
222
|
-
bottom: "512px"
|
|
223
|
-
})
|
|
224
|
-
);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it("should render the tooltip with a custom location to the top and position start", async () => {
|
|
228
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
229
|
-
...p,
|
|
230
|
-
location: "top",
|
|
231
|
-
position: "start"
|
|
232
|
-
}));
|
|
233
|
-
|
|
234
|
-
await hoverIcon();
|
|
235
|
-
|
|
236
|
-
expect(tooltip).toBeInTheDocument();
|
|
237
|
-
await waitFor(() =>
|
|
238
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
239
|
-
right: "478px",
|
|
240
|
-
bottom: "512px"
|
|
241
|
-
})
|
|
242
|
-
);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("should render the tooltip with a custom location to the top and position center", async () => {
|
|
246
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
247
|
-
...p,
|
|
248
|
-
location: "top",
|
|
249
|
-
position: "center"
|
|
250
|
-
}));
|
|
251
|
-
|
|
252
|
-
await hoverIcon();
|
|
253
|
-
|
|
254
|
-
expect(tooltip).toBeInTheDocument();
|
|
255
|
-
await waitFor(() =>
|
|
256
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
257
|
-
left: "405px",
|
|
258
|
-
bottom: "512px"
|
|
259
|
-
})
|
|
260
|
-
);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("should render the tooltip with a custom location to the bottom and position end", async () => {
|
|
264
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
265
|
-
...p,
|
|
266
|
-
location: "bottom",
|
|
267
|
-
position: "end"
|
|
268
|
-
}));
|
|
269
|
-
|
|
270
|
-
await hoverIcon();
|
|
271
|
-
|
|
272
|
-
expect(tooltip).toBeInTheDocument();
|
|
273
|
-
await waitFor(() =>
|
|
274
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
275
|
-
left: "488px",
|
|
276
|
-
top: "522px"
|
|
277
|
-
})
|
|
278
|
-
);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it("should render the tooltip with a custom location to the bottom and position start", async () => {
|
|
282
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
283
|
-
...p,
|
|
284
|
-
location: "bottom",
|
|
285
|
-
position: "start"
|
|
286
|
-
}));
|
|
287
|
-
|
|
288
|
-
await hoverIcon();
|
|
289
|
-
|
|
290
|
-
expect(tooltip).toBeInTheDocument();
|
|
291
|
-
await waitFor(() =>
|
|
292
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
293
|
-
right: "478px",
|
|
294
|
-
top: "522px"
|
|
295
|
-
})
|
|
296
|
-
);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it("should render the tooltip with a custom location to the bottom and position center", async () => {
|
|
300
|
-
const { tooltip, tooltipHoverDiv, hoverIcon } = await createTooltip(p => ({
|
|
301
|
-
...p,
|
|
302
|
-
location: "bottom",
|
|
303
|
-
position: "center"
|
|
304
|
-
}));
|
|
305
|
-
|
|
306
|
-
await hoverIcon();
|
|
307
|
-
|
|
308
|
-
expect(tooltip).toBeInTheDocument();
|
|
309
|
-
await waitFor(() =>
|
|
310
|
-
expect(tooltipHoverDiv).toHaveStyle({
|
|
311
|
-
left: "405px",
|
|
312
|
-
top: "522px"
|
|
313
|
-
})
|
|
314
|
-
);
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
describe("Colors", () => {
|
|
319
|
-
it("renders black color by default", async () => {
|
|
320
|
-
const { tooltipHoverDiv } = await createTooltip();
|
|
321
|
-
expect(tooltipHoverDiv).toHaveClass("black");
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it("renders blue color", async () => {
|
|
325
|
-
const { tooltipHoverDiv } = await createTooltip(p => ({
|
|
326
|
-
...p,
|
|
327
|
-
color: "blue"
|
|
328
|
-
}));
|
|
329
|
-
|
|
330
|
-
expect(tooltipHoverDiv).toHaveClass("blue");
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
describe("Label", () => {
|
|
335
|
-
it("can also be an element", async () => {
|
|
336
|
-
const { tooltip } = await createTooltip(p => ({ ...p, label: <span>Label</span> }));
|
|
337
|
-
|
|
338
|
-
expect(tooltip).toBeInTheDocument();
|
|
339
|
-
|
|
340
|
-
const label = tooltip.querySelector(".label");
|
|
341
|
-
expect(label).toBeInTheDocument();
|
|
342
|
-
expect(label).toHaveTextContent("Label");
|
|
343
|
-
expect((label as HTMLElement).tagName.toLowerCase()).toBe("span");
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it("Triggers visibility of the tooltip on focus and blur using keyboard", async () => {
|
|
348
|
-
const { tooltip, tooltipHoverDiv } = await createTooltip();
|
|
349
|
-
|
|
350
|
-
if (!tooltipHoverDiv) {
|
|
351
|
-
throw new Error("Tooltip hover div not found");
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const label = tooltip.querySelector(".label");
|
|
355
|
-
|
|
356
|
-
expect(label).toBeInTheDocument();
|
|
357
|
-
|
|
358
|
-
await userEvent.tab();
|
|
359
|
-
|
|
360
|
-
(label as HTMLElement).focus();
|
|
361
|
-
|
|
362
|
-
expect(tooltipHoverDiv).toHaveClass("visible");
|
|
363
|
-
|
|
364
|
-
await userEvent.tab();
|
|
365
|
-
|
|
366
|
-
expect(tooltipHoverDiv).not.toHaveClass("visible");
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
it("Sets visible to false on escape", async () => {
|
|
370
|
-
const { tooltip, tooltipHoverDiv } = await createTooltip();
|
|
371
|
-
|
|
372
|
-
if (!tooltipHoverDiv) {
|
|
373
|
-
throw new Error("Tooltip hover div not found");
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const label = tooltip.querySelector(".label");
|
|
377
|
-
|
|
378
|
-
expect(label).toBeInTheDocument();
|
|
379
|
-
|
|
380
|
-
await userEvent.tab();
|
|
381
|
-
|
|
382
|
-
(label as HTMLElement).focus();
|
|
383
|
-
|
|
384
|
-
expect(tooltipHoverDiv).toHaveClass("visible");
|
|
385
|
-
|
|
386
|
-
await userEvent.keyboard("{Escape}");
|
|
387
|
-
|
|
388
|
-
expect(tooltipHoverDiv).not.toHaveClass("visible");
|
|
389
|
-
});
|
|
390
|
-
});
|
|
@@ -1,177 +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, { useEffect, useRef } from "react";
|
|
18
|
-
import { Typography, Props } from "./Typography";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { Spacing } from "../../hooks/useSpacing";
|
|
21
|
-
|
|
22
|
-
const renderTypography = (
|
|
23
|
-
typoVariant: Props["variant"],
|
|
24
|
-
wrapper?: Props["tag"],
|
|
25
|
-
spacing?: Spacing,
|
|
26
|
-
align?: Props["align"]
|
|
27
|
-
) => {
|
|
28
|
-
const queries = render(
|
|
29
|
-
<Typography
|
|
30
|
-
variant={typoVariant}
|
|
31
|
-
tag={wrapper}
|
|
32
|
-
spacing={spacing}
|
|
33
|
-
align={align}
|
|
34
|
-
data-testid="component"
|
|
35
|
-
>
|
|
36
|
-
Test
|
|
37
|
-
</Typography>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const typography = queries.getByTestId("component");
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
...queries,
|
|
44
|
-
typography
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const className = (variant: Props["variant"]) => `typography_style_${variant}`;
|
|
49
|
-
|
|
50
|
-
describe("Typography should render", () => {
|
|
51
|
-
it("renders without crashing", () => {
|
|
52
|
-
const { typography } = renderTypography("h1");
|
|
53
|
-
expect(typography).toBeDefined();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("Should give the correct default tags and corresponding classnames", () => {
|
|
58
|
-
it("renders an h1", () => {
|
|
59
|
-
const variant = "h1";
|
|
60
|
-
const { typography } = renderTypography(variant);
|
|
61
|
-
|
|
62
|
-
expect(typography.nodeName).toBe("H1");
|
|
63
|
-
expect(typography).toHaveClass(className(variant));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("renders an h2", () => {
|
|
67
|
-
const variant = "h2";
|
|
68
|
-
const { typography } = renderTypography(variant);
|
|
69
|
-
|
|
70
|
-
expect(typography.nodeName).toBe("H2");
|
|
71
|
-
expect(typography).toHaveClass(className(variant));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("renders an h3", () => {
|
|
75
|
-
const variant = "h3";
|
|
76
|
-
const { typography } = renderTypography(variant);
|
|
77
|
-
|
|
78
|
-
expect(typography.nodeName).toBe("H3");
|
|
79
|
-
expect(typography).toHaveClass(className(variant));
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("renders an h4", () => {
|
|
83
|
-
const variant = "h4";
|
|
84
|
-
const { typography } = renderTypography(variant);
|
|
85
|
-
|
|
86
|
-
expect(typography.nodeName).toBe("H4");
|
|
87
|
-
expect(typography).toHaveClass(className(variant));
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("renders a p", () => {
|
|
91
|
-
const variant = "body";
|
|
92
|
-
const { typography } = renderTypography(variant);
|
|
93
|
-
|
|
94
|
-
expect(typography.nodeName).toBe("P");
|
|
95
|
-
expect(typography).toHaveClass(className(variant));
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("renders a p", () => {
|
|
99
|
-
const variant = "body-bold";
|
|
100
|
-
const { typography } = renderTypography(variant);
|
|
101
|
-
|
|
102
|
-
expect(typography.nodeName).toBe("P");
|
|
103
|
-
expect(typography).toHaveClass(className(variant));
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("renders a span", () => {
|
|
107
|
-
const variant = "sub-text";
|
|
108
|
-
const { typography } = renderTypography(variant);
|
|
109
|
-
|
|
110
|
-
expect(typography.nodeName).toBe("SPAN");
|
|
111
|
-
expect(typography).toHaveClass(className(variant));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("renders a code", () => {
|
|
115
|
-
const variant = "code";
|
|
116
|
-
const { typography } = renderTypography(variant);
|
|
117
|
-
|
|
118
|
-
expect(typography.nodeName).toBe("CODE");
|
|
119
|
-
expect(typography).toHaveClass(className(variant));
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe("Should override tagname", () => {
|
|
124
|
-
it("has to be a DIV element", () => {
|
|
125
|
-
const { typography } = renderTypography("h1", "div");
|
|
126
|
-
|
|
127
|
-
expect(typography.nodeName).toBe("DIV");
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
describe("Should override styling", () => {
|
|
132
|
-
it("renders h1 with overwritten margin properties", () => {
|
|
133
|
-
const { typography } = renderTypography("h1", undefined, { margin: 4, marginBottom: 8 });
|
|
134
|
-
|
|
135
|
-
expect(typography.style).toHaveProperty("margin", "1rem 1rem 2rem 1rem");
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
describe("Should override align", () => {
|
|
140
|
-
it("renders h1 with overwritten align properties", () => {
|
|
141
|
-
const { typography } = renderTypography("h1", undefined, undefined, "center");
|
|
142
|
-
|
|
143
|
-
expect(typography.style).toHaveProperty("textAlign", "center");
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("renders h1 with overwritten align properties", () => {
|
|
147
|
-
const { typography } = renderTypography("h1", undefined, undefined, "right");
|
|
148
|
-
|
|
149
|
-
expect(typography.style).toHaveProperty("textAlign", "right");
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
describe("ref should work", () => {
|
|
154
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
155
|
-
const ExampleComponent = ({
|
|
156
|
-
propagateRef
|
|
157
|
-
}: {
|
|
158
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
159
|
-
}) => {
|
|
160
|
-
const ref = useRef(null);
|
|
161
|
-
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
if (ref.current) {
|
|
164
|
-
propagateRef && propagateRef(ref);
|
|
165
|
-
}
|
|
166
|
-
}, [ref]);
|
|
167
|
-
|
|
168
|
-
return <Typography variant="body" data-ref="testing" ref={ref} />;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
172
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
@@ -1,90 +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 from "react";
|
|
18
|
-
import { BaseWizardSteps, Props } from "./BaseWizardSteps";
|
|
19
|
-
import { getAllByRole, getByText, queryByText, render } from "@testing-library/react";
|
|
20
|
-
import userEvent from "@testing-library/user-event";
|
|
21
|
-
|
|
22
|
-
const initParams: Props = {
|
|
23
|
-
steps: [
|
|
24
|
-
{
|
|
25
|
-
label: "Step 1"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
label: "Step 2"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
label: "Step 3",
|
|
32
|
-
disabled: true
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
label: "Step 4"
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
currentStepNo: 1,
|
|
39
|
-
onClick: jest.fn()
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const getStepButtons = (container: HTMLElement) => getAllByRole(container, "button");
|
|
43
|
-
|
|
44
|
-
describe("BaseWizardSteps", () => {
|
|
45
|
-
it("renders without crashing", async () => {
|
|
46
|
-
const { container } = render(<BaseWizardSteps {...initParams} />);
|
|
47
|
-
const buttons = getStepButtons(container);
|
|
48
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(0);
|
|
49
|
-
|
|
50
|
-
expect(buttons).toHaveLength(4);
|
|
51
|
-
expect(buttons[0]).not.toHaveAttribute("aria-current");
|
|
52
|
-
expect(buttons[0].querySelector(".checkmark")).toBeDefined();
|
|
53
|
-
expect(buttons[1]).toHaveAttribute("aria-current", "step");
|
|
54
|
-
expect(getByText(buttons[1], "2")).toBeDefined();
|
|
55
|
-
expect(buttons[2]).not.toHaveAttribute("aria-current");
|
|
56
|
-
expect(getByText(buttons[2], "3")).toBeDefined();
|
|
57
|
-
expect(buttons[3]).not.toHaveAttribute("aria-current");
|
|
58
|
-
expect(getByText(buttons[3], "4")).toBeDefined();
|
|
59
|
-
|
|
60
|
-
await userEvent.click(buttons[0]);
|
|
61
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(1);
|
|
62
|
-
|
|
63
|
-
await userEvent.click(buttons[1]);
|
|
64
|
-
await userEvent.click(buttons[2]);
|
|
65
|
-
await userEvent.click(buttons[3]);
|
|
66
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(1);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("should allow to click on future and prev steps but not on current and disabled steps when futureStepsClickable is enabled", async () => {
|
|
70
|
-
const { container } = render(<BaseWizardSteps {...initParams} futureStepsClickable />);
|
|
71
|
-
const buttons = getStepButtons(container);
|
|
72
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(0);
|
|
73
|
-
|
|
74
|
-
await userEvent.click(buttons[3]);
|
|
75
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(1);
|
|
76
|
-
await userEvent.click(buttons[0]);
|
|
77
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(2);
|
|
78
|
-
|
|
79
|
-
await userEvent.click(buttons[1]);
|
|
80
|
-
await userEvent.click(buttons[2]);
|
|
81
|
-
expect(initParams.onClick).toHaveBeenCalledTimes(2);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should not render checkmark or number when prev steps is disabled", () => {
|
|
85
|
-
const { container } = render(<BaseWizardSteps {...initParams} currentStepNo={3} />);
|
|
86
|
-
const buttons = getStepButtons(container);
|
|
87
|
-
|
|
88
|
-
expect(queryByText(buttons[2], "3")).toBeNull();
|
|
89
|
-
});
|
|
90
|
-
});
|