@onewelcome/react-lib-components 6.0.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/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/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.module.cjs.js +1 -1
- 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/src/.scope.d.ts +2 -0
- 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/Stepper/Stepper.d.ts +0 -1
- 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/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/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.module.esm.js +1 -1
- 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/src/.scope.d.ts +2 -0
- 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/Stepper/Stepper.d.ts +0 -1
- 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/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/Link/Link.module.scss +16 -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/hooks/usePosition.ts +1 -1
- package/src/interfaces.ts +2 -2
- package/src/mixins.module.scss +2 -4
- 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 -150
- package/src/components/Button/IconButton.test.tsx +0 -106
- 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 -203
- 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 -77
- package/src/components/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +0 -219
- package/src/components/Notifications/Snackbar/useSnackbar.test.tsx +0 -136
- 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,91 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from "react";
|
|
2
|
-
import { ProgressBar, Props } from "./ProgressBar";
|
|
3
|
-
import { render } from "@testing-library/react";
|
|
4
|
-
|
|
5
|
-
const defaultParams: Props = {
|
|
6
|
-
label: "Loading...",
|
|
7
|
-
percentage: 0,
|
|
8
|
-
accessibilityTitle: "Progress bar",
|
|
9
|
-
caption: "One moment please..."
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const createProgressBar = (params?: (defaultParams: Props) => Props) => {
|
|
13
|
-
let parameters: Props = defaultParams;
|
|
14
|
-
if (params) {
|
|
15
|
-
parameters = params(defaultParams);
|
|
16
|
-
}
|
|
17
|
-
const queries = render(<ProgressBar {...parameters} data-testid="ProgressBar" />);
|
|
18
|
-
const ProgressBarComponent = queries.getByTestId("ProgressBar");
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
...queries,
|
|
22
|
-
ProgressBarComponent
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
describe("ProgressBar should render", () => {
|
|
27
|
-
it("renders without crashing", () => {
|
|
28
|
-
const { ProgressBarComponent, getByText } = createProgressBar(defaultParams => ({
|
|
29
|
-
...defaultParams,
|
|
30
|
-
className: "test"
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
expect(ProgressBarComponent).toBeDefined();
|
|
34
|
-
expect(ProgressBarComponent).toHaveClass(`test`, { exact: true });
|
|
35
|
-
expect(ProgressBarComponent).toHaveAttribute("role", "progressbar");
|
|
36
|
-
expect(ProgressBarComponent).toHaveAttribute("aria-valuemin", "0");
|
|
37
|
-
expect(ProgressBarComponent).toHaveAttribute("aria-valuemax", "100");
|
|
38
|
-
expect(ProgressBarComponent).toHaveAttribute("aria-valuenow", "0");
|
|
39
|
-
expect(ProgressBarComponent).toHaveAttribute("title", "Progress bar");
|
|
40
|
-
expect(getByText("Loading...")).toBeDefined();
|
|
41
|
-
expect(getByText("Loading...")).toHaveClass("label");
|
|
42
|
-
expect(getByText("One moment please...")).toBeDefined();
|
|
43
|
-
expect(getByText("One moment please...")).toHaveClass("caption");
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe("ref should work", () => {
|
|
48
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
49
|
-
const ExampleComponent = ({
|
|
50
|
-
propagateRef
|
|
51
|
-
}: {
|
|
52
|
-
propagateRef: (ref: React.RefObject<HTMLElement>) => void;
|
|
53
|
-
}) => {
|
|
54
|
-
const ref = useRef(null);
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
propagateRef(ref);
|
|
58
|
-
}, [ref]);
|
|
59
|
-
|
|
60
|
-
return <ProgressBar {...defaultParams} data-ref="testing" ref={ref} />;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
64
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const container = document.createElement("div");
|
|
68
|
-
render(<ExampleComponent propagateRef={refCheck} />, { container });
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("ProgressBar should change styles depending on props", () => {
|
|
73
|
-
it("should show a progress when 'completed' prop is provided", () => {
|
|
74
|
-
const { ProgressBarComponent } = createProgressBar(defaultParams => ({
|
|
75
|
-
...defaultParams,
|
|
76
|
-
completed: 40
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
const bar = ProgressBarComponent.querySelector(".bar");
|
|
80
|
-
expect(bar).toHaveStyle("width: 40%");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should show a loading effect when 'completed' prop is not provided", () => {
|
|
84
|
-
const { ProgressBarComponent } = createProgressBar(defaultParams => ({
|
|
85
|
-
...defaultParams
|
|
86
|
-
}));
|
|
87
|
-
|
|
88
|
-
const bar = ProgressBarComponent.querySelector(".bar");
|
|
89
|
-
expect(bar).toHaveClass("loading-state");
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,112 +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 { Skeleton, Props } from "./Skeleton";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
|
|
21
|
-
const defaultParams: Props = {};
|
|
22
|
-
|
|
23
|
-
const createSkeleton = (params?: (defaultParams: Props) => Props) => {
|
|
24
|
-
let parameters: Props = defaultParams;
|
|
25
|
-
if (params) {
|
|
26
|
-
parameters = params(defaultParams);
|
|
27
|
-
}
|
|
28
|
-
const queries = render(<Skeleton {...parameters} data-testid="skeleton" />);
|
|
29
|
-
const skeleton = queries.getByTestId("skeleton");
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...queries,
|
|
33
|
-
skeleton
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
describe("Skeleton should render", () => {
|
|
38
|
-
it("renders without crashing", () => {
|
|
39
|
-
const { skeleton } = createSkeleton();
|
|
40
|
-
|
|
41
|
-
expect(skeleton).toHaveClass("skeleton text no-height", { exact: true });
|
|
42
|
-
|
|
43
|
-
expect(skeleton).toBeDefined();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("renders with properties passed", () => {
|
|
47
|
-
const testClass = "testclass";
|
|
48
|
-
const { skeleton } = createSkeleton(defaultParams => ({
|
|
49
|
-
...defaultParams,
|
|
50
|
-
className: testClass
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
expect(skeleton).toHaveClass(`skeleton text no-height ${testClass}`, { exact: true });
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("renders text variant with width and height", () => {
|
|
57
|
-
const width = "10rem";
|
|
58
|
-
const height = 10;
|
|
59
|
-
const { skeleton } = createSkeleton(defaultParams => ({
|
|
60
|
-
...defaultParams,
|
|
61
|
-
variant: "text",
|
|
62
|
-
width,
|
|
63
|
-
height
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
expect(skeleton).toHaveClass(`skeleton text`, { exact: true });
|
|
67
|
-
expect(skeleton).toHaveStyle({ width, height: "10px" });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("renders rectangle variant", () => {
|
|
71
|
-
const { skeleton } = createSkeleton(defaultParams => ({
|
|
72
|
-
...defaultParams,
|
|
73
|
-
variant: "rectangle"
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
expect(skeleton).toHaveClass(`skeleton no-height`, { exact: true });
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("renders circular variant", () => {
|
|
80
|
-
const { skeleton } = createSkeleton(defaultParams => ({
|
|
81
|
-
...defaultParams,
|
|
82
|
-
variant: "circular"
|
|
83
|
-
}));
|
|
84
|
-
|
|
85
|
-
expect(skeleton).toHaveClass(`skeleton no-height circular`, { exact: true });
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe("ref should work", () => {
|
|
90
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
91
|
-
const ExampleComponent = ({
|
|
92
|
-
propagateRef
|
|
93
|
-
}: {
|
|
94
|
-
propagateRef: (ref: React.RefObject<HTMLElement>) => void;
|
|
95
|
-
}) => {
|
|
96
|
-
const ref = useRef(null);
|
|
97
|
-
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
propagateRef(ref);
|
|
100
|
-
}, [ref]);
|
|
101
|
-
|
|
102
|
-
return <Skeleton {...defaultParams} data-ref="testing" ref={ref} />;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
106
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const container = document.createElement("div");
|
|
110
|
-
render(<ExampleComponent propagateRef={refCheck} />, { container });
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -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
|
-
});
|