@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,64 +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 { Breadcrumbs, Props } from "./Breadcrumbs";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { Link } from "../Link/Link";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {
|
|
23
|
-
ariaLabel: "Breadcrumbs",
|
|
24
|
-
children: [
|
|
25
|
-
<Link key="0" to="#1" data-testid="link">
|
|
26
|
-
Test1
|
|
27
|
-
</Link>,
|
|
28
|
-
<Link key="1" to="#2" data-testid="link">
|
|
29
|
-
Test2
|
|
30
|
-
</Link>
|
|
31
|
-
]
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const createBreadcrumbs = (params?: (defaultParams: Props) => Props) => {
|
|
35
|
-
let parameters: Props = defaultParams;
|
|
36
|
-
if (params) {
|
|
37
|
-
parameters = params(defaultParams);
|
|
38
|
-
}
|
|
39
|
-
const queries = render(<Breadcrumbs {...parameters} data-testid="breadcrumbs"></Breadcrumbs>);
|
|
40
|
-
const breadcrumbs = queries.getByTestId("breadcrumbs");
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
...queries,
|
|
44
|
-
breadcrumbs
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
describe("Breadcrumbs should render", () => {
|
|
49
|
-
it("renders without crashing", () => {
|
|
50
|
-
const { breadcrumbs } = createBreadcrumbs();
|
|
51
|
-
|
|
52
|
-
expect(breadcrumbs).toBeDefined();
|
|
53
|
-
expect(breadcrumbs.firstChild).not.toHaveAttribute("aria-current");
|
|
54
|
-
if (breadcrumbs.firstChild) {
|
|
55
|
-
const homeIcon = (breadcrumbs.firstChild as HTMLElement).querySelector(
|
|
56
|
-
"[class*='icon-home-filled']"
|
|
57
|
-
);
|
|
58
|
-
expect(homeIcon).toBeInTheDocument();
|
|
59
|
-
}
|
|
60
|
-
expect((breadcrumbs.firstChild as HTMLElement).tagName).toEqual("A");
|
|
61
|
-
expect(breadcrumbs.lastChild).toHaveAttribute("aria-current", "page");
|
|
62
|
-
expect((breadcrumbs.lastChild as HTMLElement).tagName).toEqual("SPAN");
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,133 +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 { BaseButton, Props } from "./BaseButton";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import userEvent from "@testing-library/user-event";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {};
|
|
23
|
-
|
|
24
|
-
const createBaseButton = (params?: (defaultParams: Props) => Props) => {
|
|
25
|
-
let parameters: Props = defaultParams;
|
|
26
|
-
if (params) {
|
|
27
|
-
parameters = params(defaultParams);
|
|
28
|
-
}
|
|
29
|
-
const queries = render(
|
|
30
|
-
<BaseButton {...parameters} data-testid="baseButton">
|
|
31
|
-
baseButton content
|
|
32
|
-
</BaseButton>
|
|
33
|
-
);
|
|
34
|
-
const baseButton = queries.getByTestId("baseButton");
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
...queries,
|
|
38
|
-
baseButton
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
describe("BaseButton should render", () => {
|
|
43
|
-
it("renders without crashing", () => {
|
|
44
|
-
const { baseButton } = createBaseButton();
|
|
45
|
-
|
|
46
|
-
expect(baseButton).toBeDefined();
|
|
47
|
-
expect(baseButton).toHaveTextContent("baseButton content");
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe("On click handler", () => {
|
|
52
|
-
it("executes the onclick handler", async () => {
|
|
53
|
-
const onClickHandler = jest.fn();
|
|
54
|
-
const { baseButton } = createBaseButton(defaultParams => ({
|
|
55
|
-
...defaultParams,
|
|
56
|
-
onClick: onClickHandler
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
await userEvent.click(baseButton);
|
|
60
|
-
|
|
61
|
-
expect(onClickHandler).toBeCalled();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("Properties of the button", () => {
|
|
66
|
-
it("should be disabled, function should not have been called", async () => {
|
|
67
|
-
const onClickHandler = jest.fn();
|
|
68
|
-
const { baseButton } = createBaseButton(defaultParams => ({
|
|
69
|
-
...defaultParams,
|
|
70
|
-
disabled: true,
|
|
71
|
-
onClick: onClickHandler
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
await userEvent.click(baseButton);
|
|
75
|
-
expect(onClickHandler).toHaveBeenCalledTimes(0);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("when loading onClick function should not have been called", async () => {
|
|
79
|
-
const onClickHandler = jest.fn();
|
|
80
|
-
const { baseButton } = createBaseButton(defaultParams => ({
|
|
81
|
-
...defaultParams,
|
|
82
|
-
loading: true,
|
|
83
|
-
onClick: onClickHandler
|
|
84
|
-
}));
|
|
85
|
-
|
|
86
|
-
await userEvent.click(baseButton);
|
|
87
|
-
expect(onClickHandler).toHaveBeenCalledTimes(0);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should have the class "TESTING"', () => {
|
|
91
|
-
const { baseButton } = createBaseButton(defaultParams => ({
|
|
92
|
-
...defaultParams,
|
|
93
|
-
className: "TESTING"
|
|
94
|
-
}));
|
|
95
|
-
|
|
96
|
-
expect(baseButton).toHaveClass("TESTING");
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should have a "name" property with the value "button"', () => {
|
|
100
|
-
const { baseButton } = createBaseButton(defaultParams => ({
|
|
101
|
-
...defaultParams,
|
|
102
|
-
name: "button"
|
|
103
|
-
}));
|
|
104
|
-
|
|
105
|
-
expect(baseButton).toHaveAttribute("name", "button");
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe("ref should work", () => {
|
|
110
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
111
|
-
const ExampleComponent = ({
|
|
112
|
-
propagateRef
|
|
113
|
-
}: {
|
|
114
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
115
|
-
}) => {
|
|
116
|
-
const ref = useRef(null);
|
|
117
|
-
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
if (ref.current) {
|
|
120
|
-
propagateRef && propagateRef(ref);
|
|
121
|
-
}
|
|
122
|
-
}, [ref]);
|
|
123
|
-
|
|
124
|
-
return <BaseButton {...defaultParams} data-ref="testing" ref={ref} />;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
128
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,138 +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, { useRef, useEffect } from "react";
|
|
18
|
-
import { Button, Props } from "./Button";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { Icon, Icons } from "../Icon/Icon";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {};
|
|
23
|
-
|
|
24
|
-
const createButton = (params?: (defaultParams: Props) => Props) => {
|
|
25
|
-
let parameters: Props = defaultParams;
|
|
26
|
-
if (params) {
|
|
27
|
-
parameters = params(defaultParams);
|
|
28
|
-
}
|
|
29
|
-
const queries = render(
|
|
30
|
-
<Button {...parameters} data-testid="button">
|
|
31
|
-
button content
|
|
32
|
-
</Button>
|
|
33
|
-
);
|
|
34
|
-
const button = queries.getByTestId("button");
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
...queries,
|
|
38
|
-
button
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
describe("Button should render", () => {
|
|
43
|
-
it("renders without crashing", () => {
|
|
44
|
-
const { button } = createButton();
|
|
45
|
-
|
|
46
|
-
expect(button).toBeDefined();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe("ref should work", () => {
|
|
51
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
52
|
-
const ExampleComponent = ({
|
|
53
|
-
propagateRef
|
|
54
|
-
}: {
|
|
55
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
56
|
-
}) => {
|
|
57
|
-
const ref = useRef(null);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (ref.current) {
|
|
61
|
-
propagateRef && propagateRef(ref);
|
|
62
|
-
}
|
|
63
|
-
}, [ref]);
|
|
64
|
-
|
|
65
|
-
return <Button {...defaultParams} data-ref="testing" ref={ref} />;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
69
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe("Button should render", () => {
|
|
77
|
-
it("renders without crashing", () => {
|
|
78
|
-
const { button } = createButton();
|
|
79
|
-
|
|
80
|
-
expect(button).toBeDefined();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe("Different variants of the button", () => {
|
|
85
|
-
it('should have a class of "primary"', () => {
|
|
86
|
-
const { button } = createButton();
|
|
87
|
-
expect(button.classList.contains("primary")).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should have a class of "secondary"', () => {
|
|
91
|
-
const { button } = createButton(defaultParams => ({ ...defaultParams, color: "secondary" }));
|
|
92
|
-
expect(button.classList.contains("secondary")).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should have a class of "warning"', () => {
|
|
96
|
-
const { button } = createButton(defaultParams => ({ ...defaultParams, color: "warning" }));
|
|
97
|
-
expect(button.classList.contains("warning")).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should have a class of "fill"', () => {
|
|
101
|
-
const { button } = createButton(defaultParams => ({ ...defaultParams, variant: "fill" }));
|
|
102
|
-
expect(button.classList.contains("fill")).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should have a class of "outline"', () => {
|
|
106
|
-
const { button } = createButton(defaultParams => ({ ...defaultParams, variant: "outline" }));
|
|
107
|
-
expect(button.classList.contains("outline")).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('should have a class of "text"', () => {
|
|
111
|
-
const { button } = createButton(defaultParams => ({ ...defaultParams, variant: "text" }));
|
|
112
|
-
expect(button.classList.contains("text")).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe("Button contains an icon", () => {
|
|
117
|
-
it("Contains an icon at the start", () => {
|
|
118
|
-
const { button } = createButton(defaultParams => ({
|
|
119
|
-
...defaultParams,
|
|
120
|
-
startIcon: <Icon icon={Icons.Calendar} />
|
|
121
|
-
}));
|
|
122
|
-
|
|
123
|
-
expect(button.classList.contains("has-icon")).toBe(true);
|
|
124
|
-
expect(button.firstElementChild?.nodeName).toBe("I");
|
|
125
|
-
expect(button.querySelector("i + span")!.innerHTML).toBe("button content");
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("Contains an icon at the end", () => {
|
|
129
|
-
const { button } = createButton(defaultParams => ({
|
|
130
|
-
...defaultParams,
|
|
131
|
-
endIcon: <Icon icon={Icons.Calendar} />
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
expect(button.classList.contains("has-icon")).toBe(true);
|
|
135
|
-
expect(button.lastElementChild?.nodeName).toBe("I");
|
|
136
|
-
expect(button.querySelector("span")!.innerHTML).toBe("button content");
|
|
137
|
-
});
|
|
138
|
-
});
|
|
@@ -1,122 +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, { useRef, useEffect } from "react";
|
|
18
|
-
import { IconButton, Props } from "./IconButton";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
|
|
21
|
-
const defaultParams: Props = {
|
|
22
|
-
title: "iconbutton"
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const createIconButton = (params?: (defaultParams: Props) => Props) => {
|
|
26
|
-
let parameters: Props = defaultParams;
|
|
27
|
-
if (params) {
|
|
28
|
-
parameters = params(defaultParams);
|
|
29
|
-
}
|
|
30
|
-
const queries = render(
|
|
31
|
-
<IconButton {...parameters} data-testid="iconButton">
|
|
32
|
-
iconButton content
|
|
33
|
-
</IconButton>
|
|
34
|
-
);
|
|
35
|
-
const iconButton = queries.getByTestId("iconButton");
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
...queries,
|
|
39
|
-
iconButton
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
describe("IconButton should render", () => {
|
|
44
|
-
it("renders without crashing", () => {
|
|
45
|
-
const { iconButton } = createIconButton();
|
|
46
|
-
|
|
47
|
-
expect(iconButton).toBeDefined();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe("ref should work", () => {
|
|
52
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
53
|
-
const ExampleComponent = ({
|
|
54
|
-
propagateRef
|
|
55
|
-
}: {
|
|
56
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
57
|
-
}) => {
|
|
58
|
-
const ref = useRef(null);
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (ref.current) {
|
|
62
|
-
propagateRef && propagateRef(ref);
|
|
63
|
-
}
|
|
64
|
-
}, [ref]);
|
|
65
|
-
|
|
66
|
-
return <IconButton {...defaultParams} data-ref="testing" ref={ref} />;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
70
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("Different variants of the button", () => {
|
|
78
|
-
it('should have a class of "primary"', () => {
|
|
79
|
-
const { iconButton } = createIconButton();
|
|
80
|
-
expect(iconButton.classList.contains("primary")).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should have a class of "secondary"', () => {
|
|
84
|
-
const { iconButton } = createIconButton(defaultParams => ({
|
|
85
|
-
...defaultParams,
|
|
86
|
-
color: "secondary"
|
|
87
|
-
}));
|
|
88
|
-
expect(iconButton.classList.contains("secondary")).toBe(true);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should have a class of "warning"', () => {
|
|
92
|
-
const { iconButton } = createIconButton(defaultParams => ({
|
|
93
|
-
...defaultParams,
|
|
94
|
-
color: "warning"
|
|
95
|
-
}));
|
|
96
|
-
expect(iconButton.classList.contains("warning")).toBe(true);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should have a class of "fill"', () => {
|
|
100
|
-
const { iconButton } = createIconButton(defaultParams => ({
|
|
101
|
-
...defaultParams,
|
|
102
|
-
variant: "fill"
|
|
103
|
-
}));
|
|
104
|
-
expect(iconButton.classList.contains("fill")).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('should have a class of "outline"', () => {
|
|
108
|
-
const { iconButton } = createIconButton(defaultParams => ({
|
|
109
|
-
...defaultParams,
|
|
110
|
-
variant: "outline"
|
|
111
|
-
}));
|
|
112
|
-
expect(iconButton.classList.contains("outline")).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should have a class of "text"', () => {
|
|
116
|
-
const { iconButton } = createIconButton(defaultParams => ({
|
|
117
|
-
...defaultParams,
|
|
118
|
-
variant: "text"
|
|
119
|
-
}));
|
|
120
|
-
expect(iconButton.classList.contains("text")).toBe(true);
|
|
121
|
-
});
|
|
122
|
-
});
|