@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,186 +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 { SelectWrapper, Props } from "./SelectWrapper";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { Option } from "../../Select/Option";
|
|
21
|
-
import userEvent from "@testing-library/user-event";
|
|
22
|
-
|
|
23
|
-
const onChangeHandler = jest.fn();
|
|
24
|
-
|
|
25
|
-
const defaultParams: Props = {
|
|
26
|
-
success: false,
|
|
27
|
-
children: [
|
|
28
|
-
<Option key="1" value="option1">
|
|
29
|
-
Option 1
|
|
30
|
-
</Option>,
|
|
31
|
-
<Option key="2" value="option2">
|
|
32
|
-
Option 2
|
|
33
|
-
</Option>,
|
|
34
|
-
<Option key="3" value="option3">
|
|
35
|
-
Option 3
|
|
36
|
-
</Option>,
|
|
37
|
-
<Option key="4" value="option4">
|
|
38
|
-
Option 4
|
|
39
|
-
</Option>
|
|
40
|
-
],
|
|
41
|
-
label: "select_label",
|
|
42
|
-
name: "select",
|
|
43
|
-
helperText: "helpertext",
|
|
44
|
-
helperProps: { "data-testid": "helpertext" },
|
|
45
|
-
errorMessage: "errormessage",
|
|
46
|
-
error: false,
|
|
47
|
-
value: "option1",
|
|
48
|
-
onChange: onChangeHandler
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const createSelectWrapper = (params?: (defaultParams: Props) => Props) => {
|
|
52
|
-
let parameters: Props = defaultParams;
|
|
53
|
-
if (params) {
|
|
54
|
-
parameters = params(defaultParams);
|
|
55
|
-
}
|
|
56
|
-
const queries = render(<SelectWrapper {...parameters} data-testid="selectwrapper" />);
|
|
57
|
-
const selectwrapper = queries.getByTestId("selectwrapper");
|
|
58
|
-
const select = selectwrapper.querySelector("button");
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
...queries,
|
|
62
|
-
selectwrapper,
|
|
63
|
-
select
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
describe("SelectWrapper should render", () => {
|
|
68
|
-
it("renders without crashing", () => {
|
|
69
|
-
const { selectwrapper } = createSelectWrapper();
|
|
70
|
-
|
|
71
|
-
expect(selectwrapper).toBeDefined();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe("ref should work", () => {
|
|
76
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
77
|
-
const ExampleComponent = ({
|
|
78
|
-
propagateRef
|
|
79
|
-
}: {
|
|
80
|
-
propagateRef?: (
|
|
81
|
-
ref: React.RefObject<HTMLElement>,
|
|
82
|
-
innerRef: React.RefObject<HTMLInputElement>
|
|
83
|
-
) => void;
|
|
84
|
-
}) => {
|
|
85
|
-
const ref = useRef(null);
|
|
86
|
-
const innerRef = useRef(null);
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (ref.current) {
|
|
90
|
-
propagateRef && propagateRef(ref, innerRef);
|
|
91
|
-
}
|
|
92
|
-
}, [ref]);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<SelectWrapper
|
|
96
|
-
{...defaultParams}
|
|
97
|
-
selectProps={{ ref: innerRef, "data-ref": "inner-testing" }}
|
|
98
|
-
name="test"
|
|
99
|
-
data-ref="testing"
|
|
100
|
-
ref={ref}
|
|
101
|
-
/>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const refCheck = (
|
|
106
|
-
ref: React.RefObject<HTMLElement>,
|
|
107
|
-
innerRef: React.RefObject<HTMLElement>
|
|
108
|
-
) => {
|
|
109
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
110
|
-
expect(innerRef.current!.nodeName).toBe("SELECT");
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe("SelectWrapper & Select have the right attributes", () => {
|
|
118
|
-
it("select has aria values", async () => {
|
|
119
|
-
const { select, getByTestId, findByText } = createSelectWrapper();
|
|
120
|
-
|
|
121
|
-
const helpertext = getByTestId("helpertext");
|
|
122
|
-
const label = await findByText("select_label");
|
|
123
|
-
|
|
124
|
-
expect(select).toHaveAttribute("aria-describedby", helpertext.id);
|
|
125
|
-
expect(select).toHaveAttribute("aria-labelledby", label.id);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("SelectWrapper has the right helpertext", () => {
|
|
129
|
-
const { getByTestId } = createSelectWrapper();
|
|
130
|
-
|
|
131
|
-
const helpertext = getByTestId("helpertext");
|
|
132
|
-
|
|
133
|
-
expect(helpertext).toBeTruthy();
|
|
134
|
-
expect(helpertext).toHaveTextContent("helpertext");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("Passes the proper helperProps class", () => {
|
|
138
|
-
const { getByTestId } = createSelectWrapper(defaultParams => ({
|
|
139
|
-
...defaultParams,
|
|
140
|
-
helperProps: { ...defaultParams.helperProps, className: "example-helper-classname" }
|
|
141
|
-
}));
|
|
142
|
-
|
|
143
|
-
const helpertext = getByTestId("helpertext");
|
|
144
|
-
|
|
145
|
-
expect(helpertext.parentElement).toHaveClass("example-helper-classname");
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("Passes the proper selectProps class", () => {
|
|
149
|
-
const { getByTestId } = createSelectWrapper(defaultParams => ({
|
|
150
|
-
...defaultParams,
|
|
151
|
-
selectProps: {
|
|
152
|
-
...defaultParams.selectProps,
|
|
153
|
-
"data-testid": "select-element",
|
|
154
|
-
className: "example-select-classname"
|
|
155
|
-
}
|
|
156
|
-
}));
|
|
157
|
-
|
|
158
|
-
const select = getByTestId("select-element");
|
|
159
|
-
|
|
160
|
-
expect(select).toHaveClass("example-select-classname");
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("SelectWrapper has the right errormessage", async () => {
|
|
164
|
-
const { findByText, select } = createSelectWrapper(defaultParams => ({
|
|
165
|
-
...defaultParams,
|
|
166
|
-
error: true
|
|
167
|
-
}));
|
|
168
|
-
|
|
169
|
-
const errorMessage = await findByText("errormessage");
|
|
170
|
-
|
|
171
|
-
expect(errorMessage).toBeTruthy();
|
|
172
|
-
expect(select).toHaveAttribute("aria-describedby", errorMessage.id);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("Fires the onChange event", async () => {
|
|
176
|
-
const { select, findByText } = createSelectWrapper();
|
|
177
|
-
|
|
178
|
-
await userEvent.click(select as Element);
|
|
179
|
-
|
|
180
|
-
const option3 = await findByText("Option 3");
|
|
181
|
-
|
|
182
|
-
await userEvent.click(option3 as Element);
|
|
183
|
-
|
|
184
|
-
expect(onChangeHandler).toHaveBeenCalled();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,173 +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 { TextareaWrapper, Props } from "./TextareaWrapper";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import userEvent from "@testing-library/user-event";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {
|
|
23
|
-
success: false,
|
|
24
|
-
name: "textarea",
|
|
25
|
-
label: "textarea_label",
|
|
26
|
-
value: "value",
|
|
27
|
-
error: false,
|
|
28
|
-
helperText: "helpertext",
|
|
29
|
-
helperProps: { "data-testid": "helpertext" },
|
|
30
|
-
errorMessage: "errormessage",
|
|
31
|
-
textareaProps: { "data-testid": "textarea" },
|
|
32
|
-
onChange: jest.fn()
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const createTextareaWrapper = (params?: (defaultParams: Props) => Props) => {
|
|
36
|
-
let parameters: Props = defaultParams;
|
|
37
|
-
if (params) {
|
|
38
|
-
parameters = params(defaultParams);
|
|
39
|
-
}
|
|
40
|
-
const queries = render(<TextareaWrapper {...parameters} data-testid="textareawrapper" />);
|
|
41
|
-
const textareawrapper = queries.getByTestId("textareawrapper");
|
|
42
|
-
const textarea = queries.getByTestId("textarea");
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
...queries,
|
|
46
|
-
textareawrapper,
|
|
47
|
-
textarea
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
describe("TextareaWrapper should render", () => {
|
|
52
|
-
it("renders without crashing", () => {
|
|
53
|
-
const { textareawrapper } = createTextareaWrapper();
|
|
54
|
-
|
|
55
|
-
expect(textareawrapper).toBeDefined();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("ref should work", () => {
|
|
60
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
61
|
-
const ExampleComponent = ({
|
|
62
|
-
propagateRef
|
|
63
|
-
}: {
|
|
64
|
-
propagateRef?: (
|
|
65
|
-
ref: React.RefObject<HTMLElement>,
|
|
66
|
-
innerRef: React.RefObject<HTMLInputElement>
|
|
67
|
-
) => void;
|
|
68
|
-
}) => {
|
|
69
|
-
const ref = useRef(null);
|
|
70
|
-
const innerRef = useRef(null);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (ref.current) {
|
|
74
|
-
propagateRef && propagateRef(ref, innerRef);
|
|
75
|
-
}
|
|
76
|
-
}, [ref]);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<TextareaWrapper
|
|
80
|
-
{...defaultParams}
|
|
81
|
-
textareaProps={{ ref: innerRef, "data-ref": "inner-testing" }}
|
|
82
|
-
name="test"
|
|
83
|
-
data-ref="testing"
|
|
84
|
-
ref={ref}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const refCheck = (
|
|
90
|
-
ref: React.RefObject<HTMLElement>,
|
|
91
|
-
innerRef: React.RefObject<HTMLElement>
|
|
92
|
-
) => {
|
|
93
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
94
|
-
expect(innerRef.current).toHaveAttribute("data-ref", "inner-testing");
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe("TextareaWrapper & Textarea have the right attributes", () => {
|
|
102
|
-
it("textarea has aria values", async () => {
|
|
103
|
-
const { textarea, getByTestId, findByText } = createTextareaWrapper();
|
|
104
|
-
|
|
105
|
-
const helpertext = getByTestId("helpertext");
|
|
106
|
-
const label = await findByText("textarea_label");
|
|
107
|
-
|
|
108
|
-
expect(textarea).toHaveAttribute("aria-describedby", helpertext.id);
|
|
109
|
-
expect(textarea).toHaveAttribute("aria-labelledby", label.id);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("TextareaWrapper has the right helpertext", () => {
|
|
113
|
-
const { getByTestId } = createTextareaWrapper();
|
|
114
|
-
|
|
115
|
-
const helpertext = getByTestId("helpertext");
|
|
116
|
-
|
|
117
|
-
expect(helpertext).toBeTruthy();
|
|
118
|
-
expect(helpertext).toHaveTextContent("helpertext");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("TextareaWrapper has the right errormessage", async () => {
|
|
122
|
-
const { findByText, textarea } = createTextareaWrapper(defaultParams => ({
|
|
123
|
-
...defaultParams,
|
|
124
|
-
error: true
|
|
125
|
-
}));
|
|
126
|
-
|
|
127
|
-
const errorMessage = await findByText("errormessage");
|
|
128
|
-
|
|
129
|
-
expect(errorMessage).toBeTruthy();
|
|
130
|
-
expect(textarea).toHaveAttribute("aria-describedby", errorMessage.id);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe("TextarenaWrapper should be interactive", () => {
|
|
135
|
-
it("Fires the onChange, onFocus & onBlur events", async () => {
|
|
136
|
-
const onFocusHandler = jest.fn();
|
|
137
|
-
const onChangeHandler = jest.fn();
|
|
138
|
-
const onBlurHandler = jest.fn();
|
|
139
|
-
|
|
140
|
-
const { textarea } = createTextareaWrapper(defaultParams => ({
|
|
141
|
-
...defaultParams,
|
|
142
|
-
onChange: onChangeHandler,
|
|
143
|
-
onFocus: onFocusHandler,
|
|
144
|
-
onBlur: onBlurHandler
|
|
145
|
-
}));
|
|
146
|
-
|
|
147
|
-
await userEvent.tab();
|
|
148
|
-
expect(textarea).toHaveFocus();
|
|
149
|
-
|
|
150
|
-
await userEvent.keyboard("input");
|
|
151
|
-
await userEvent.tab();
|
|
152
|
-
|
|
153
|
-
expect(onChangeHandler).toHaveBeenCalledTimes(5);
|
|
154
|
-
expect(onFocusHandler).toHaveBeenCalled();
|
|
155
|
-
expect(onBlurHandler).toHaveBeenCalled();
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("Fires the onMouseEnter & onMouseLeave events", async () => {
|
|
159
|
-
const onMouseEnterHandler = jest.fn();
|
|
160
|
-
const onMouseLeaveHandler = jest.fn();
|
|
161
|
-
|
|
162
|
-
const { textarea } = createTextareaWrapper(defaultParams => ({
|
|
163
|
-
...defaultParams,
|
|
164
|
-
onMouseEnter: onMouseEnterHandler,
|
|
165
|
-
onMouseLeave: onMouseLeaveHandler
|
|
166
|
-
}));
|
|
167
|
-
|
|
168
|
-
await userEvent.hover(textarea);
|
|
169
|
-
expect(onMouseEnterHandler).toHaveBeenCalled();
|
|
170
|
-
await userEvent.unhover(textarea);
|
|
171
|
-
expect(onMouseLeaveHandler).toHaveBeenCalled();
|
|
172
|
-
});
|
|
173
|
-
});
|
|
@@ -1,59 +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 { Wrapper } from "./Wrapper";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { Input } from "../../Input/Input";
|
|
21
|
-
|
|
22
|
-
describe("Wrapper should render", () => {
|
|
23
|
-
it("renders without crashing", () => {
|
|
24
|
-
const { container } = render(
|
|
25
|
-
<Wrapper label="label" name="name" helperId="helperID">
|
|
26
|
-
<Input onChange={jest.fn()} name="test" type="text" value="test" />
|
|
27
|
-
</Wrapper>
|
|
28
|
-
);
|
|
29
|
-
const wrapper = container.querySelector(".wrapper");
|
|
30
|
-
|
|
31
|
-
expect(wrapper).toBeDefined();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("ref should work", () => {
|
|
36
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
37
|
-
const ExampleComponent = ({
|
|
38
|
-
propagateRef
|
|
39
|
-
}: {
|
|
40
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
41
|
-
}) => {
|
|
42
|
-
const ref = useRef(null);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (ref.current) {
|
|
46
|
-
propagateRef && propagateRef(ref);
|
|
47
|
-
}
|
|
48
|
-
}, [ref]);
|
|
49
|
-
|
|
50
|
-
return <Wrapper name="wrapper" children={<div></div>} data-ref="testing" ref={ref} />;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
54
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,83 +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 { Icon, Props, Icons } from "./Icon";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
|
|
21
|
-
interface PartialProps extends Omit<Props, "ref"> {}
|
|
22
|
-
|
|
23
|
-
const initParams: PartialProps = {
|
|
24
|
-
icon: Icons.Calendar,
|
|
25
|
-
color: "rgb(26, 153, 60)"
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const createIcon = (params = initParams) => {
|
|
29
|
-
const queries = render(
|
|
30
|
-
<Icon {...params} data-testid="icon-component" color={params.color} icon={params.icon} />
|
|
31
|
-
);
|
|
32
|
-
const icon = queries.getByTestId("icon-component");
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
...queries,
|
|
36
|
-
icon
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
describe("Icon", () => {
|
|
41
|
-
it("renders without crashing", () => {
|
|
42
|
-
const { icon } = createIcon();
|
|
43
|
-
|
|
44
|
-
expect(icon).toBeDefined();
|
|
45
|
-
expect(icon).toHaveClass("icon-calendar");
|
|
46
|
-
expect(icon.tagName.toLowerCase()).toBe("span");
|
|
47
|
-
expect(icon.getAttribute("style")).toBe("color: rgb(26, 153, 60);");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should render icon with within div tag", () => {
|
|
51
|
-
const tag = "div";
|
|
52
|
-
const { icon } = createIcon({ ...initParams, tag });
|
|
53
|
-
|
|
54
|
-
expect(icon).toBeDefined();
|
|
55
|
-
expect(icon.tagName.toLowerCase()).toBe(tag);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("ref should work", () => {
|
|
60
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
61
|
-
const ExampleComponent = ({
|
|
62
|
-
propagateRef
|
|
63
|
-
}: {
|
|
64
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
65
|
-
}) => {
|
|
66
|
-
const ref = useRef(null);
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (ref.current) {
|
|
70
|
-
propagateRef && propagateRef(ref);
|
|
71
|
-
}
|
|
72
|
-
}, [ref]);
|
|
73
|
-
|
|
74
|
-
return <Icon {...initParams} data-ref="testing" ref={ref} />;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
78
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,203 +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 { Link, Props } from "./Link";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { BrowserRouter, Link as RouterLink } from "react-router-dom";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {
|
|
23
|
-
type: "external",
|
|
24
|
-
to: "https://www.google.com"
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const createLink = (params?: (defaultParams: Props) => Props) => {
|
|
28
|
-
let parameters: Props = defaultParams;
|
|
29
|
-
if (params) {
|
|
30
|
-
parameters = params(defaultParams);
|
|
31
|
-
}
|
|
32
|
-
const queries = render(
|
|
33
|
-
<Link {...parameters} data-testid="link">
|
|
34
|
-
link content
|
|
35
|
-
</Link>
|
|
36
|
-
);
|
|
37
|
-
const link = queries.getByTestId("link");
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
...queries,
|
|
41
|
-
link
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
describe("Link should render", () => {
|
|
46
|
-
it("renders without crashing", () => {
|
|
47
|
-
const { link } = createLink();
|
|
48
|
-
|
|
49
|
-
expect(link).toBeTruthy();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("is an external link with the right attributes", () => {
|
|
53
|
-
const { link } = createLink();
|
|
54
|
-
|
|
55
|
-
expect(link).toHaveAttribute("aria-disabled", "false");
|
|
56
|
-
expect(link).toHaveAttribute("rel", "noopener noreferer");
|
|
57
|
-
expect(link).toHaveAttribute("target", "_blank");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("is an internal link with the right attributes", () => {
|
|
61
|
-
const { link } = createLink(defaultParams => ({
|
|
62
|
-
...defaultParams,
|
|
63
|
-
type: "internal",
|
|
64
|
-
to: "/home"
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
expect(link).toHaveAttribute("aria-disabled", "false");
|
|
68
|
-
expect(link).not.toHaveAttribute("rel", "noopener noreferer");
|
|
69
|
-
expect(link).not.toHaveAttribute("target", "_blank");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("is a download link with the right attributes", () => {
|
|
73
|
-
const { link } = createLink(defaultParams => ({
|
|
74
|
-
...defaultParams,
|
|
75
|
-
type: "download",
|
|
76
|
-
to: "/test.png"
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
expect(link).toHaveAttribute("aria-disabled", "false");
|
|
80
|
-
expect(link).not.toHaveAttribute("rel", "noopener noreferer");
|
|
81
|
-
expect(link).not.toHaveAttribute("target", "_blank");
|
|
82
|
-
expect(link).toHaveAttribute("download");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("should set the correct target", () => {
|
|
86
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, target: "_parent" }));
|
|
87
|
-
|
|
88
|
-
expect(link).toHaveAttribute("target", "_parent");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("should accept this React Router Link prop and render as such", () => {
|
|
92
|
-
const queries = render(
|
|
93
|
-
<BrowserRouter>
|
|
94
|
-
<Link to="/contact" component={RouterLink} children="Routerlink" />
|
|
95
|
-
</BrowserRouter>
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
const routerLink = queries.getByText("Routerlink");
|
|
99
|
-
|
|
100
|
-
expect(routerLink).toBeTruthy();
|
|
101
|
-
expect(routerLink).toHaveClass("link");
|
|
102
|
-
expect(routerLink).toHaveAttribute("href", "/contact");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should be disabled", () => {
|
|
106
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, disabled: true }));
|
|
107
|
-
|
|
108
|
-
expect(link).not.toHaveAttribute("href");
|
|
109
|
-
expect(link).toHaveClass("disabled");
|
|
110
|
-
expect(link).toHaveStyle({ color: "var(--greyed-out)" });
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("should have a className added", () => {
|
|
114
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, className: "classname" }));
|
|
115
|
-
|
|
116
|
-
expect(link).toHaveClass("classname");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("should render as a filled button ", () => {
|
|
120
|
-
const { link } = createLink(defaultParams => ({
|
|
121
|
-
...defaultParams,
|
|
122
|
-
display: "button",
|
|
123
|
-
buttonVariant: "fill"
|
|
124
|
-
}));
|
|
125
|
-
|
|
126
|
-
expect(link).toHaveClass("button");
|
|
127
|
-
expect(link).toHaveClass("fill");
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("should render as a text button ", () => {
|
|
131
|
-
const { link } = createLink(defaultParams => ({
|
|
132
|
-
...defaultParams,
|
|
133
|
-
display: "button",
|
|
134
|
-
buttonVariant: "text"
|
|
135
|
-
}));
|
|
136
|
-
|
|
137
|
-
expect(link).toHaveClass("button");
|
|
138
|
-
expect(link).toHaveClass("text");
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("should render as an outline button ", () => {
|
|
142
|
-
const { link } = createLink(defaultParams => ({
|
|
143
|
-
...defaultParams,
|
|
144
|
-
display: "button",
|
|
145
|
-
buttonVariant: "outline"
|
|
146
|
-
}));
|
|
147
|
-
|
|
148
|
-
expect(link).toHaveClass("button");
|
|
149
|
-
expect(link).toHaveClass("outline");
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
describe("ref should work", () => {
|
|
154
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
155
|
-
const ExampleComponent = ({
|
|
156
|
-
propagateRef
|
|
157
|
-
}: {
|
|
158
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
159
|
-
}) => {
|
|
160
|
-
const ref = useRef(null);
|
|
161
|
-
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
if (ref.current) {
|
|
164
|
-
propagateRef && propagateRef(ref);
|
|
165
|
-
}
|
|
166
|
-
}, [ref]);
|
|
167
|
-
|
|
168
|
-
return <Link {...defaultParams} data-ref="testing" ref={ref} />;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
172
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
describe("colors", () => {
|
|
180
|
-
it("should be color primary", () => {
|
|
181
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "primary" }));
|
|
182
|
-
|
|
183
|
-
expect(link).toHaveStyle({ color: "var(--color-primary)" });
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("should be color secondary", () => {
|
|
187
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "success" }));
|
|
188
|
-
|
|
189
|
-
expect(link).toHaveStyle({ color: "var(--color-success)" });
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("should be color danger", () => {
|
|
193
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "danger" }));
|
|
194
|
-
|
|
195
|
-
expect(link).toHaveStyle({ color: "var(--color-danger)" });
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("should be color warning", () => {
|
|
199
|
-
const { link } = createLink(defaultParams => ({ ...defaultParams, color: "warning" }));
|
|
200
|
-
|
|
201
|
-
expect(link).toHaveStyle({ color: "var(--color-warning)" });
|
|
202
|
-
});
|
|
203
|
-
});
|