@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,143 +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 { StatusIndicator, Props } from "./StatusIndicator";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
|
|
21
|
-
const defaultParams: Props = {
|
|
22
|
-
status: "active"
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const createStatusIndicator = (params?: (defaultParams: Props) => Props) => {
|
|
26
|
-
let parameters: Props = defaultParams;
|
|
27
|
-
if (params) {
|
|
28
|
-
parameters = params(defaultParams);
|
|
29
|
-
}
|
|
30
|
-
const queries = render(
|
|
31
|
-
<StatusIndicator {...parameters} data-testid="StatusIndicator">
|
|
32
|
-
content
|
|
33
|
-
</StatusIndicator>
|
|
34
|
-
);
|
|
35
|
-
const statusIndicator = queries.getByTestId("StatusIndicator");
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
...queries,
|
|
39
|
-
statusIndicator
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
describe("StatusIndicator should render", () => {
|
|
44
|
-
it("renders without crashing", () => {
|
|
45
|
-
const { statusIndicator, getByText } = createStatusIndicator();
|
|
46
|
-
|
|
47
|
-
expect(statusIndicator).toBeDefined();
|
|
48
|
-
expect(getByText("content")).toBeInTheDocument();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("passes through custom typography props", () => {
|
|
52
|
-
const { statusIndicator, getByText } = createStatusIndicator(params => ({
|
|
53
|
-
...params,
|
|
54
|
-
typographyProps: {
|
|
55
|
-
variant: "body",
|
|
56
|
-
children: <strong>custom children</strong>
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
expect(statusIndicator).toBeDefined();
|
|
61
|
-
expect(getByText("custom children")).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("passes through custom props", () => {
|
|
65
|
-
const { statusIndicator } = createStatusIndicator(params => ({
|
|
66
|
-
...params,
|
|
67
|
-
"aria-label": "status indicator"
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
expect(statusIndicator).toBeDefined();
|
|
71
|
-
expect(statusIndicator).toHaveAttribute("aria-label", "status indicator");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('should set "active" class on status badge', () => {
|
|
75
|
-
const { statusIndicator } = createStatusIndicator(params => ({
|
|
76
|
-
...params,
|
|
77
|
-
status: "active"
|
|
78
|
-
}));
|
|
79
|
-
|
|
80
|
-
expect(statusIndicator.firstChild).toHaveClass("active");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should set "error" class on status badge', () => {
|
|
84
|
-
const { statusIndicator } = createStatusIndicator(params => ({ ...params, status: "error" }));
|
|
85
|
-
|
|
86
|
-
expect(statusIndicator.firstChild).toHaveClass("error");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should set "neutral" class on status badge', () => {
|
|
90
|
-
const { statusIndicator } = createStatusIndicator(params => ({
|
|
91
|
-
...params,
|
|
92
|
-
status: "neutral"
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
expect(statusIndicator.firstChild).toHaveClass("neutral");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should pass "warning" class to status badge', () => {
|
|
99
|
-
const { statusIndicator } = createStatusIndicator(params => ({
|
|
100
|
-
...params,
|
|
101
|
-
status: "warning"
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
expect(statusIndicator.firstChild).toHaveClass("warning");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should pass custom class to status badge", () => {
|
|
108
|
-
const { statusIndicator } = createStatusIndicator(params => ({
|
|
109
|
-
...params,
|
|
110
|
-
badgeProps: { className: "custom" }
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
expect(statusIndicator.firstChild).toHaveClass("custom");
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("ref should work", () => {
|
|
118
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
119
|
-
const ExampleComponent = ({
|
|
120
|
-
propagateRef
|
|
121
|
-
}: {
|
|
122
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
123
|
-
}) => {
|
|
124
|
-
const ref = useRef(null);
|
|
125
|
-
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
if (ref.current) {
|
|
128
|
-
propagateRef && propagateRef(ref);
|
|
129
|
-
}
|
|
130
|
-
}, [ref]);
|
|
131
|
-
|
|
132
|
-
return (
|
|
133
|
-
<StatusIndicator id="test" children="test" data-ref="testing" ref={ref} status="active" />
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
138
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Stepper, Props } from "./Stepper";
|
|
3
|
-
import { render } from "@testing-library/react";
|
|
4
|
-
|
|
5
|
-
const defaultParams: Props = {
|
|
6
|
-
steps: [],
|
|
7
|
-
direction: "horizontal"
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const createStepper = (params?: (defaultParams: Props) => Props) => {
|
|
11
|
-
let parameters: Props = defaultParams;
|
|
12
|
-
if (params) {
|
|
13
|
-
parameters = params(defaultParams);
|
|
14
|
-
}
|
|
15
|
-
const queries = render(<Stepper {...parameters} data-testid="Stepper" />);
|
|
16
|
-
const StepperComponent = queries.getByTestId("Stepper");
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
...queries,
|
|
20
|
-
StepperComponent
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
describe("<Stepper/> should render", () => {
|
|
25
|
-
it("should render without crashing", () => {
|
|
26
|
-
const { StepperComponent } = createStepper();
|
|
27
|
-
|
|
28
|
-
expect(StepperComponent).toBeDefined();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should render given steps", () => {
|
|
32
|
-
const { StepperComponent, getAllByText } = createStepper(params => ({
|
|
33
|
-
...params,
|
|
34
|
-
steps: [
|
|
35
|
-
{
|
|
36
|
-
label: "Step 1",
|
|
37
|
-
status: "waiting",
|
|
38
|
-
caption: "Caption"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: "Step 2",
|
|
42
|
-
status: "current",
|
|
43
|
-
caption: "Caption"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
label: "Step 3",
|
|
47
|
-
status: "done",
|
|
48
|
-
caption: "Caption"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
label: "Step 4",
|
|
52
|
-
status: "error",
|
|
53
|
-
caption: "Caption"
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
expect(StepperComponent).toBeDefined();
|
|
59
|
-
|
|
60
|
-
expect(getAllByText(/Step/i)).toHaveLength(4);
|
|
61
|
-
expect(getAllByText(/Caption/i)).toHaveLength(4);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should render the horizontal stepper", () => {
|
|
65
|
-
const { StepperComponent } = createStepper(params => ({
|
|
66
|
-
...params,
|
|
67
|
-
direction: "horizontal"
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
expect(StepperComponent).toBeDefined();
|
|
71
|
-
expect(StepperComponent.classList).toContain("horizontal");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("should render the vertical stepper", () => {
|
|
75
|
-
const { StepperComponent } = createStepper(params => ({
|
|
76
|
-
...params,
|
|
77
|
-
direction: "vertical"
|
|
78
|
-
}));
|
|
79
|
-
|
|
80
|
-
expect(StepperComponent).toBeDefined();
|
|
81
|
-
expect(StepperComponent.classList).not.toContain("horizontal");
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,49 +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 { Tab, Props } from "./Tab";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
|
|
21
|
-
const defaultParams: Props = {
|
|
22
|
-
title: "Title of tab"
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const createTab = (params?: (defaultParams: Props) => Props) => {
|
|
26
|
-
let parameters: Props = defaultParams;
|
|
27
|
-
if (params) {
|
|
28
|
-
parameters = params(defaultParams);
|
|
29
|
-
}
|
|
30
|
-
const queries = render(
|
|
31
|
-
<Tab {...parameters} data-testid="tab">
|
|
32
|
-
tab content
|
|
33
|
-
</Tab>
|
|
34
|
-
);
|
|
35
|
-
const tab = queries.getByTestId("tab");
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
...queries,
|
|
39
|
-
tab
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
describe("Tab should render", () => {
|
|
44
|
-
it("renders without crashing", () => {
|
|
45
|
-
const { tab } = createTab();
|
|
46
|
-
|
|
47
|
-
expect(tab).toBeTruthy();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -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 from "react";
|
|
18
|
-
import { Props, TabButton } from "./TabButton";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
|
|
21
|
-
const defaultParams: Props = {};
|
|
22
|
-
|
|
23
|
-
const createTabButton = (params?: (defaultParams: Props) => Props) => {
|
|
24
|
-
let parameters: Props = defaultParams;
|
|
25
|
-
if (params) {
|
|
26
|
-
parameters = params(defaultParams);
|
|
27
|
-
}
|
|
28
|
-
const queries = render(
|
|
29
|
-
<TabButton {...parameters} data-testid="tabbutton">
|
|
30
|
-
tab content
|
|
31
|
-
</TabButton>
|
|
32
|
-
);
|
|
33
|
-
const tabButton = queries.getByTestId("tabbutton");
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...queries,
|
|
37
|
-
tabButton
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
describe("Tab should render", () => {
|
|
42
|
-
it("renders without crashing", () => {
|
|
43
|
-
const { tabButton } = createTabButton();
|
|
44
|
-
|
|
45
|
-
expect(tabButton).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("should be focussed when prop focused is passed", () => {
|
|
49
|
-
const { tabButton } = createTabButton(defaultParams => ({
|
|
50
|
-
...defaultParams,
|
|
51
|
-
focused: true
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
expect(tabButton).toHaveFocus();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should set class when prop className is passed", () => {
|
|
58
|
-
const { tabButton } = createTabButton(defaultParams => ({
|
|
59
|
-
...defaultParams,
|
|
60
|
-
className: "customclass"
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
expect(tabButton).toHaveClass("customclass");
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,291 +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 { Tabs, Props } from "./Tabs";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { TabButton as Tab } from "./TabButton";
|
|
21
|
-
import userEvent from "@testing-library/user-event";
|
|
22
|
-
import { act } from "react-dom/test-utils";
|
|
23
|
-
|
|
24
|
-
const defaultParams: Props = {
|
|
25
|
-
children: [
|
|
26
|
-
<Tab key="tab1" title="Tab1">
|
|
27
|
-
Tabpanel1 content
|
|
28
|
-
</Tab>,
|
|
29
|
-
<Tab key="tab2" title="Tab2">
|
|
30
|
-
Tabpanel2 content
|
|
31
|
-
</Tab>,
|
|
32
|
-
<Tab key="tab3" title="Tab3">
|
|
33
|
-
Tabpanel3 content
|
|
34
|
-
</Tab>
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const createTabs = (params?: (defaultParams: Props) => Props) => {
|
|
39
|
-
let parameters: Props = defaultParams;
|
|
40
|
-
if (params) {
|
|
41
|
-
parameters = params(defaultParams);
|
|
42
|
-
}
|
|
43
|
-
const queries = render(<Tabs {...parameters} data-testid="tabs"></Tabs>);
|
|
44
|
-
const tabs = queries.getByTestId("tabs");
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
...queries,
|
|
48
|
-
tabs
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
describe("Tabs should render", () => {
|
|
53
|
-
it("renders without crashing", () => {
|
|
54
|
-
const { tabs } = createTabs();
|
|
55
|
-
|
|
56
|
-
expect(tabs).toBeDefined();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("renders with properties passed", () => {
|
|
60
|
-
const { tabs } = createTabs(defaultParams => ({
|
|
61
|
-
...defaultParams,
|
|
62
|
-
className: "testclass"
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
expect(tabs).toHaveClass("testclass");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("switches to tab and tabpanel when selected property is changed", () => {
|
|
69
|
-
const { tabs } = createTabs(defaultParams => ({
|
|
70
|
-
...defaultParams,
|
|
71
|
-
selected: 2
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
const tablist = tabs.firstChild as HTMLDivElement;
|
|
75
|
-
const tabpanels = tabs.lastChild as HTMLDivElement;
|
|
76
|
-
const tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
77
|
-
|
|
78
|
-
const tab1 = tabButtons[0] as HTMLButtonElement;
|
|
79
|
-
const tab3 = tabButtons[2] as HTMLButtonElement;
|
|
80
|
-
|
|
81
|
-
const tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
82
|
-
const tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
83
|
-
|
|
84
|
-
expect(tab1).not.toHaveClass("selected");
|
|
85
|
-
expect(tab3).toHaveClass("selected");
|
|
86
|
-
|
|
87
|
-
expect(tabpanel1).not.toHaveClass("selected");
|
|
88
|
-
expect(tabpanel3).toHaveClass("selected");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("switches to tab and tabpanel when tab is clicked", async () => {
|
|
92
|
-
const { tabs } = createTabs(defaultParams => ({
|
|
93
|
-
...defaultParams
|
|
94
|
-
}));
|
|
95
|
-
|
|
96
|
-
const tablist = tabs.firstChild as HTMLDivElement;
|
|
97
|
-
const tabpanels = tabs.lastChild as HTMLDivElement;
|
|
98
|
-
let tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
99
|
-
|
|
100
|
-
let tab1 = tabButtons[0] as HTMLButtonElement;
|
|
101
|
-
let tab3 = tabButtons[2] as HTMLButtonElement;
|
|
102
|
-
|
|
103
|
-
let tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
104
|
-
let tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
105
|
-
|
|
106
|
-
expect(tab1).toHaveClass("selected");
|
|
107
|
-
expect(tab3).not.toHaveClass("selected");
|
|
108
|
-
|
|
109
|
-
expect(tabpanel1).toHaveClass("selected");
|
|
110
|
-
expect(tabpanel3).not.toHaveClass("selected");
|
|
111
|
-
|
|
112
|
-
await userEvent.click(tab3);
|
|
113
|
-
|
|
114
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
115
|
-
|
|
116
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
117
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
118
|
-
|
|
119
|
-
tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
120
|
-
tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
121
|
-
|
|
122
|
-
expect(tab1).not.toHaveClass("selected");
|
|
123
|
-
expect(tab3).toHaveClass("selected");
|
|
124
|
-
|
|
125
|
-
expect(tabpanel1).not.toHaveClass("selected");
|
|
126
|
-
expect(tabpanel3).toHaveClass("selected");
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("triggers the onTabChange when switching tabs", async () => {
|
|
130
|
-
const onTabChangeHandler = jest.fn();
|
|
131
|
-
|
|
132
|
-
const { tabs } = createTabs(defaultParams => ({
|
|
133
|
-
...defaultParams,
|
|
134
|
-
onTabChange: onTabChangeHandler
|
|
135
|
-
}));
|
|
136
|
-
|
|
137
|
-
const tablist = tabs.firstChild as HTMLDivElement;
|
|
138
|
-
const tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
139
|
-
|
|
140
|
-
let tab3 = tabButtons[2] as HTMLButtonElement;
|
|
141
|
-
|
|
142
|
-
await userEvent.click(tab3);
|
|
143
|
-
|
|
144
|
-
expect(onTabChangeHandler).toHaveBeenCalled();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe("Tabs should not render other children then tab components", () => {
|
|
149
|
-
it("renders no tabs", () => {
|
|
150
|
-
const queries = render(
|
|
151
|
-
<Tabs data-testid="tabs">
|
|
152
|
-
<div>wrong component 1</div>
|
|
153
|
-
<div>wrong component 2</div>
|
|
154
|
-
</Tabs>
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const tabs = queries.getByTestId("tabs");
|
|
158
|
-
expect(tabs).toBeDefined();
|
|
159
|
-
expect(tabs).toBeEmptyDOMElement;
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe("Tabs should comply with accessibility rules", () => {
|
|
164
|
-
it("traverse through tabs with keyboard", async () => {
|
|
165
|
-
const { tabs } = createTabs();
|
|
166
|
-
|
|
167
|
-
const tablist = tabs.firstChild as HTMLDivElement;
|
|
168
|
-
const tabpanels = tabs.lastChild as HTMLDivElement;
|
|
169
|
-
let tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
170
|
-
|
|
171
|
-
let tab1 = tabButtons[0] as HTMLButtonElement;
|
|
172
|
-
let tab3 = tabButtons[2] as HTMLButtonElement;
|
|
173
|
-
|
|
174
|
-
let tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
175
|
-
let tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
176
|
-
|
|
177
|
-
act(() => {
|
|
178
|
-
tab1.focus();
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
182
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
183
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
184
|
-
tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
185
|
-
tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
186
|
-
|
|
187
|
-
expect(tab1).toHaveFocus();
|
|
188
|
-
expect(tab1).toHaveClass("selected");
|
|
189
|
-
expect(tab3).not.toHaveClass("selected");
|
|
190
|
-
expect(tab3).not.toHaveFocus();
|
|
191
|
-
expect(tabpanel1).toHaveClass("selected");
|
|
192
|
-
expect(tabpanel3).not.toHaveClass("selected");
|
|
193
|
-
|
|
194
|
-
await userEvent.keyboard("[ArrowLeft]");
|
|
195
|
-
await userEvent.keyboard("[Space]");
|
|
196
|
-
|
|
197
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
198
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
199
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
200
|
-
tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
201
|
-
tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
202
|
-
|
|
203
|
-
expect(tab3).toHaveFocus();
|
|
204
|
-
expect(tab3).toHaveClass("selected");
|
|
205
|
-
expect(tab1).not.toHaveClass("selected");
|
|
206
|
-
expect(tab1).not.toHaveFocus();
|
|
207
|
-
expect(tabpanel3).toHaveClass("selected");
|
|
208
|
-
expect(tabpanel1).not.toHaveClass("selected");
|
|
209
|
-
|
|
210
|
-
await userEvent.keyboard("[ArrowRight]");
|
|
211
|
-
await userEvent.keyboard("[Enter]");
|
|
212
|
-
|
|
213
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
214
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
215
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
216
|
-
tabpanel1 = tabpanels.firstChild as HTMLDivElement;
|
|
217
|
-
tabpanel3 = tabpanels.lastChild as HTMLDivElement;
|
|
218
|
-
|
|
219
|
-
expect(tab1).toHaveFocus();
|
|
220
|
-
expect(tab1).toHaveClass("selected");
|
|
221
|
-
expect(tab3).not.toHaveClass("selected");
|
|
222
|
-
expect(tab3).not.toHaveFocus();
|
|
223
|
-
expect(tabpanel1).toHaveClass("selected");
|
|
224
|
-
expect(tabpanel3).not.toHaveClass("selected");
|
|
225
|
-
|
|
226
|
-
await userEvent.keyboard("[End]");
|
|
227
|
-
|
|
228
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
229
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
230
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
231
|
-
|
|
232
|
-
expect(tab3).toHaveFocus();
|
|
233
|
-
expect(tab3).toHaveFocus();
|
|
234
|
-
expect(tab1).not.toHaveFocus();
|
|
235
|
-
|
|
236
|
-
await userEvent.keyboard("[Home]");
|
|
237
|
-
|
|
238
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
239
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
240
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
241
|
-
|
|
242
|
-
expect(tab1).toHaveFocus();
|
|
243
|
-
expect(tab1).toHaveClass("selected");
|
|
244
|
-
expect(tab3).not.toHaveFocus();
|
|
245
|
-
|
|
246
|
-
// should have no effect
|
|
247
|
-
await userEvent.keyboard("a");
|
|
248
|
-
|
|
249
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
250
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
251
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
252
|
-
|
|
253
|
-
expect(tab1).toHaveFocus();
|
|
254
|
-
expect(tab1).toHaveClass("selected");
|
|
255
|
-
expect(tab3).not.toHaveFocus();
|
|
256
|
-
|
|
257
|
-
await userEvent.keyboard("[ArrowRight]");
|
|
258
|
-
|
|
259
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
260
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
261
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
262
|
-
|
|
263
|
-
expect(tab1).not.toHaveFocus();
|
|
264
|
-
expect(tab3).not.toHaveFocus();
|
|
265
|
-
expect(tab1).not.toHaveFocus();
|
|
266
|
-
expect(tab3).not.toHaveFocus();
|
|
267
|
-
|
|
268
|
-
await userEvent.keyboard("[ArrowLeft]");
|
|
269
|
-
|
|
270
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
271
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
272
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
273
|
-
|
|
274
|
-
expect(tab1).toHaveFocus();
|
|
275
|
-
expect(tab1).toHaveClass("selected");
|
|
276
|
-
expect(tab3).not.toHaveFocus();
|
|
277
|
-
|
|
278
|
-
await userEvent.keyboard("[ArrowLeft]");
|
|
279
|
-
|
|
280
|
-
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
281
|
-
tab1 = tabButtons[0] as HTMLButtonElement;
|
|
282
|
-
tab3 = tabButtons[2] as HTMLButtonElement;
|
|
283
|
-
|
|
284
|
-
act(() => {
|
|
285
|
-
tab3.blur();
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
expect(tab1).not.toHaveFocus();
|
|
289
|
-
expect(tab3).not.toHaveFocus();
|
|
290
|
-
});
|
|
291
|
-
});
|