@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,219 +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, useState } from "react";
|
|
18
|
-
import {
|
|
19
|
-
render,
|
|
20
|
-
getByTestId,
|
|
21
|
-
getAllByText,
|
|
22
|
-
waitFor,
|
|
23
|
-
getAllByRole,
|
|
24
|
-
getByText,
|
|
25
|
-
fireEvent
|
|
26
|
-
} from "@testing-library/react";
|
|
27
|
-
import { SnackbarProvider, Props } from "./SnackbarProvider";
|
|
28
|
-
import { useSnackbar } from "../useSnackbar";
|
|
29
|
-
import userEvent from "@testing-library/user-event";
|
|
30
|
-
|
|
31
|
-
const successProps = {
|
|
32
|
-
title: "success title",
|
|
33
|
-
options: {
|
|
34
|
-
duration: 10,
|
|
35
|
-
onClose: jest.fn()
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const errorProps = {
|
|
40
|
-
title: "error title",
|
|
41
|
-
options: {
|
|
42
|
-
duration: 10,
|
|
43
|
-
onClose: jest.fn()
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const infoProps = {
|
|
48
|
-
title: "info title",
|
|
49
|
-
content: "test content",
|
|
50
|
-
options: {
|
|
51
|
-
actions: [
|
|
52
|
-
{ label: "Contact support", onClick: jest.fn() },
|
|
53
|
-
{ label: "Contact Onewelcome", onClick: jest.fn() }
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const warningProps = {
|
|
59
|
-
title: "warning title",
|
|
60
|
-
options: {
|
|
61
|
-
duration: 10,
|
|
62
|
-
onClose: jest.fn()
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
67
|
-
const AppComponent = () => {
|
|
68
|
-
const {
|
|
69
|
-
enqueueSuccessSnackbar,
|
|
70
|
-
enqueueErrorSnackbar,
|
|
71
|
-
enqueueSnackbar,
|
|
72
|
-
enqueueWarningSnackbar
|
|
73
|
-
} = useSnackbar();
|
|
74
|
-
const [index, setIndex] = useState(0);
|
|
75
|
-
return (
|
|
76
|
-
<div>
|
|
77
|
-
content
|
|
78
|
-
<button
|
|
79
|
-
data-testid="show-success"
|
|
80
|
-
onClick={() => {
|
|
81
|
-
enqueueSuccessSnackbar({ title: successProps.title + index, ...successProps.options });
|
|
82
|
-
setIndex(index + 1);
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
Success
|
|
86
|
-
</button>
|
|
87
|
-
<button
|
|
88
|
-
data-testid="show-error"
|
|
89
|
-
onClick={() => {
|
|
90
|
-
enqueueErrorSnackbar({ title: errorProps.title + index });
|
|
91
|
-
setIndex(index + 1);
|
|
92
|
-
}}
|
|
93
|
-
>
|
|
94
|
-
Error
|
|
95
|
-
</button>
|
|
96
|
-
<button
|
|
97
|
-
data-testid="show-info"
|
|
98
|
-
onClick={() => {
|
|
99
|
-
enqueueSnackbar({
|
|
100
|
-
title: infoProps.title + index,
|
|
101
|
-
content: infoProps.content,
|
|
102
|
-
...infoProps.options
|
|
103
|
-
});
|
|
104
|
-
setIndex(index + 1);
|
|
105
|
-
}}
|
|
106
|
-
>
|
|
107
|
-
Info
|
|
108
|
-
</button>
|
|
109
|
-
<button
|
|
110
|
-
data-testid="show-warning"
|
|
111
|
-
onClick={() => {
|
|
112
|
-
enqueueWarningSnackbar({ title: warningProps.title + index, ...warningProps.options });
|
|
113
|
-
setIndex(index + 1);
|
|
114
|
-
}}
|
|
115
|
-
>
|
|
116
|
-
Warning
|
|
117
|
-
</button>
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const queries = render(
|
|
123
|
-
<SnackbarProvider {...props} closeButtonTitle="close">
|
|
124
|
-
<AppComponent />
|
|
125
|
-
</SnackbarProvider>
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const showSuccessSnackbarBtn = getByTestId(queries.container, "show-success");
|
|
129
|
-
const showErrorSnackbarBtn = getByTestId(queries.container, "show-error");
|
|
130
|
-
const showInfoSnackbarBtn = getByTestId(queries.container, "show-info");
|
|
131
|
-
const showWarningSnackbarBtn = getByTestId(queries.container, "show-warning");
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
...queries,
|
|
135
|
-
showSuccessSnackbarBtn,
|
|
136
|
-
showErrorSnackbarBtn,
|
|
137
|
-
showInfoSnackbarBtn,
|
|
138
|
-
showWarningSnackbarBtn
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
describe("<SnackbarProvider />", () => {
|
|
143
|
-
it("should render without crashing", () => {
|
|
144
|
-
const { container } = renderSnackbarProvider();
|
|
145
|
-
|
|
146
|
-
expect(container).toHaveTextContent("content");
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("should stack 3 snackbars at one time", async () => {
|
|
150
|
-
const { showSuccessSnackbarBtn, showWarningSnackbarBtn } = renderSnackbarProvider();
|
|
151
|
-
|
|
152
|
-
await userEvent.click(showSuccessSnackbarBtn);
|
|
153
|
-
await userEvent.click(showWarningSnackbarBtn);
|
|
154
|
-
await userEvent.click(showSuccessSnackbarBtn);
|
|
155
|
-
await userEvent.click(showSuccessSnackbarBtn);
|
|
156
|
-
|
|
157
|
-
await waitFor(() => {
|
|
158
|
-
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(2);
|
|
159
|
-
expect(getAllByText(document.body, new RegExp(warningProps.title))).toHaveLength(1);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("should render 3 variants of snackbars", async () => {
|
|
164
|
-
const { showSuccessSnackbarBtn, showErrorSnackbarBtn, showInfoSnackbarBtn } =
|
|
165
|
-
renderSnackbarProvider();
|
|
166
|
-
|
|
167
|
-
await userEvent.click(showSuccessSnackbarBtn);
|
|
168
|
-
await userEvent.click(showErrorSnackbarBtn);
|
|
169
|
-
await userEvent.click(showInfoSnackbarBtn);
|
|
170
|
-
|
|
171
|
-
expect(getByText(document.body, new RegExp(successProps.title))).toBeDefined();
|
|
172
|
-
expect(getByText(document.body, new RegExp(errorProps.title))).toBeDefined();
|
|
173
|
-
expect(getByText(document.body, new RegExp(infoProps.title))).toBeDefined();
|
|
174
|
-
expect(getByText(document.body, infoProps.content)).toBeDefined();
|
|
175
|
-
const infoSnackbarActions = getAllByRole(document.body, "button", { name: /Contact/i });
|
|
176
|
-
expect(infoSnackbarActions).toHaveLength(2);
|
|
177
|
-
|
|
178
|
-
await userEvent.click(infoSnackbarActions[0]);
|
|
179
|
-
await userEvent.click(infoSnackbarActions[1]);
|
|
180
|
-
|
|
181
|
-
expect(infoProps.options.actions[0].onClick).toBeCalledTimes(1);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
describe("handlers", () => {
|
|
185
|
-
it("should fire onClose", async () => {
|
|
186
|
-
const onCloseHandler = jest.fn();
|
|
187
|
-
const ExampleComponent = () => {
|
|
188
|
-
const { enqueueErrorSnackbar, enqueueSuccessSnackbar } = useSnackbar();
|
|
189
|
-
|
|
190
|
-
useEffect(() => {
|
|
191
|
-
enqueueErrorSnackbar("error", undefined, { onClose: onCloseHandler, duration: 1 });
|
|
192
|
-
enqueueSuccessSnackbar("success", undefined, { onClose: onCloseHandler, duration: 1 });
|
|
193
|
-
}, []);
|
|
194
|
-
|
|
195
|
-
return <div></div>;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const queries = render(
|
|
199
|
-
<SnackbarProvider closeButtonTitle="close">
|
|
200
|
-
<ExampleComponent />
|
|
201
|
-
</SnackbarProvider>
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const errorSnackbar = await queries.findByText(/error/i);
|
|
205
|
-
const successSnackbar = await queries.findByText(/success/i);
|
|
206
|
-
|
|
207
|
-
expect(errorSnackbar).toBeTruthy();
|
|
208
|
-
expect(successSnackbar).toBeTruthy();
|
|
209
|
-
|
|
210
|
-
const parentErrorSnackbar = errorSnackbar.closest(".snackbar")!;
|
|
211
|
-
const parentSuccessSnackbar = successSnackbar.closest(".snackbar")!;
|
|
212
|
-
|
|
213
|
-
fireEvent.animationEnd(parentErrorSnackbar);
|
|
214
|
-
fireEvent.animationEnd(parentSuccessSnackbar);
|
|
215
|
-
|
|
216
|
-
await waitFor(() => expect(onCloseHandler).toHaveBeenCalledTimes(2));
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
});
|
|
@@ -1,136 +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
|
-
import React from "react";
|
|
17
|
-
import { act, renderHook } from "@testing-library/react";
|
|
18
|
-
import { useSnackbar } from "./useSnackbar";
|
|
19
|
-
import { SnackbarProvider } from "./SnackbarProvider/SnackbarProvider";
|
|
20
|
-
|
|
21
|
-
describe("useNotificationContext", () => {
|
|
22
|
-
it("should return the correct context", () => {
|
|
23
|
-
const { result } = renderHook(() => useSnackbar(), {
|
|
24
|
-
wrapper: ({ children }) => (
|
|
25
|
-
<SnackbarProvider closeButtonTitle="close">{children}</SnackbarProvider>
|
|
26
|
-
)
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(result.current).toEqual({
|
|
30
|
-
enqueueWarningSnackbar: expect.any(Function),
|
|
31
|
-
enqueueErrorSnackbar: expect.any(Function),
|
|
32
|
-
enqueueSuccessSnackbar: expect.any(Function),
|
|
33
|
-
enqueueSnackbar: expect.any(Function)
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should call new API", () => {
|
|
38
|
-
const { result } = renderHook(() => useSnackbar(), {
|
|
39
|
-
wrapper: ({ children }) => (
|
|
40
|
-
<SnackbarProvider closeButtonTitle="close">{children}</SnackbarProvider>
|
|
41
|
-
)
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
act(() => {
|
|
45
|
-
result.current.enqueueSnackbar({ title: "title" });
|
|
46
|
-
result.current.enqueueSnackbar({ title: "title", content: "content" });
|
|
47
|
-
result.current.enqueueSnackbar({
|
|
48
|
-
title: "title",
|
|
49
|
-
content: "content",
|
|
50
|
-
onClose: () => {},
|
|
51
|
-
actions: []
|
|
52
|
-
});
|
|
53
|
-
result.current.enqueueSnackbar({ content: "content" });
|
|
54
|
-
result.current.enqueueSnackbar({ content: "content", className: "123" });
|
|
55
|
-
result.current.enqueueSnackbar({ title: "title", variant: "error", duration: 123 });
|
|
56
|
-
|
|
57
|
-
result.current.enqueueErrorSnackbar({ title: "title" });
|
|
58
|
-
result.current.enqueueErrorSnackbar({ title: "title", content: "content" });
|
|
59
|
-
result.current.enqueueErrorSnackbar({
|
|
60
|
-
title: "title",
|
|
61
|
-
content: "content",
|
|
62
|
-
onClose: () => {},
|
|
63
|
-
actions: []
|
|
64
|
-
});
|
|
65
|
-
result.current.enqueueErrorSnackbar({ content: "content" });
|
|
66
|
-
result.current.enqueueErrorSnackbar({ content: "content", className: "123" });
|
|
67
|
-
result.current.enqueueErrorSnackbar({ title: "title", duration: 123 });
|
|
68
|
-
|
|
69
|
-
result.current.enqueueSuccessSnackbar({ title: "title" });
|
|
70
|
-
result.current.enqueueSuccessSnackbar({ title: "title", content: "content" });
|
|
71
|
-
result.current.enqueueSuccessSnackbar({
|
|
72
|
-
title: "title",
|
|
73
|
-
content: "content",
|
|
74
|
-
onClose: () => {},
|
|
75
|
-
actions: []
|
|
76
|
-
});
|
|
77
|
-
result.current.enqueueSuccessSnackbar({ content: "content" });
|
|
78
|
-
result.current.enqueueSuccessSnackbar({ content: "content", className: "123" });
|
|
79
|
-
result.current.enqueueSuccessSnackbar({ title: "title", duration: 123 });
|
|
80
|
-
|
|
81
|
-
result.current.enqueueWarningSnackbar({ title: "title" });
|
|
82
|
-
result.current.enqueueWarningSnackbar({ title: "title", content: "content" });
|
|
83
|
-
result.current.enqueueWarningSnackbar({
|
|
84
|
-
title: "title",
|
|
85
|
-
content: "content",
|
|
86
|
-
onClose: () => {},
|
|
87
|
-
actions: []
|
|
88
|
-
});
|
|
89
|
-
result.current.enqueueWarningSnackbar({ content: "content" });
|
|
90
|
-
result.current.enqueueWarningSnackbar({ content: "content", className: "123" });
|
|
91
|
-
result.current.enqueueWarningSnackbar({ title: "title", duration: 123 });
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("should call deprecated API", () => {
|
|
96
|
-
const { result } = renderHook(() => useSnackbar(), {
|
|
97
|
-
wrapper: ({ children }) => (
|
|
98
|
-
<SnackbarProvider closeButtonTitle="close">{children}</SnackbarProvider>
|
|
99
|
-
)
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
act(() => {
|
|
103
|
-
result.current.enqueueSnackbar("title");
|
|
104
|
-
result.current.enqueueSnackbar("title", "content");
|
|
105
|
-
result.current.enqueueSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
106
|
-
result.current.enqueueSnackbar(undefined, "content");
|
|
107
|
-
result.current.enqueueSnackbar(undefined, "content", { className: "123" });
|
|
108
|
-
result.current.enqueueSnackbar("title", undefined, { variant: "error", duration: 123 });
|
|
109
|
-
|
|
110
|
-
result.current.enqueueErrorSnackbar("title");
|
|
111
|
-
result.current.enqueueErrorSnackbar("title", "content");
|
|
112
|
-
result.current.enqueueErrorSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
113
|
-
result.current.enqueueErrorSnackbar(undefined, "content");
|
|
114
|
-
result.current.enqueueErrorSnackbar(undefined, "content", { className: "123" });
|
|
115
|
-
result.current.enqueueErrorSnackbar("title", undefined, { duration: 123 });
|
|
116
|
-
|
|
117
|
-
result.current.enqueueSuccessSnackbar("title");
|
|
118
|
-
result.current.enqueueSuccessSnackbar("title", "content");
|
|
119
|
-
result.current.enqueueSuccessSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
120
|
-
result.current.enqueueSuccessSnackbar(undefined, "content");
|
|
121
|
-
result.current.enqueueSuccessSnackbar(undefined, "content", { className: "123" });
|
|
122
|
-
result.current.enqueueSuccessSnackbar("title", undefined, {
|
|
123
|
-
duration: 123
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
result.current.enqueueWarningSnackbar("title");
|
|
127
|
-
result.current.enqueueWarningSnackbar("title", "content");
|
|
128
|
-
result.current.enqueueWarningSnackbar("title", "content", { onClose: () => {}, actions: [] });
|
|
129
|
-
result.current.enqueueWarningSnackbar(undefined, "content");
|
|
130
|
-
result.current.enqueueWarningSnackbar(undefined, "content", { className: "123" });
|
|
131
|
-
result.current.enqueueWarningSnackbar("title", undefined, {
|
|
132
|
-
duration: 123
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1,183 +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 { Pagination, Props } from "./Pagination";
|
|
19
|
-
import { render, waitFor } from "@testing-library/react";
|
|
20
|
-
import userEvent from "@testing-library/user-event";
|
|
21
|
-
|
|
22
|
-
const defaultParams: Props = {
|
|
23
|
-
currentPage: 1,
|
|
24
|
-
totalElements: 500,
|
|
25
|
-
onPageChange: jest.fn(),
|
|
26
|
-
onPageSizeChange: jest.fn()
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const createPagination = (params?: (defaultParams: Props) => Props) => {
|
|
30
|
-
let parameters: Props = defaultParams;
|
|
31
|
-
|
|
32
|
-
if (params) {
|
|
33
|
-
parameters = params(defaultParams);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const queries = render(<Pagination data-testid="pagination" {...parameters} />);
|
|
37
|
-
|
|
38
|
-
const pagination = queries.getByTestId("pagination");
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...queries,
|
|
42
|
-
pagination
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
describe("Pagination should render", () => {
|
|
47
|
-
it("renders without crashing", () => {
|
|
48
|
-
const { pagination } = createPagination();
|
|
49
|
-
|
|
50
|
-
expect(pagination).toBeTruthy();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("Pagination events", () => {
|
|
55
|
-
it("should correctly translate user input to pagination component", async () => {
|
|
56
|
-
const onPageChange = jest.fn();
|
|
57
|
-
|
|
58
|
-
const onPageSizeChange = jest.fn();
|
|
59
|
-
|
|
60
|
-
const { pagination } = createPagination(defaultParams => ({
|
|
61
|
-
...defaultParams,
|
|
62
|
-
currentPage: 10,
|
|
63
|
-
onPageChange,
|
|
64
|
-
onPageSizeChange
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
const next = pagination.querySelector('[data-paginate="next"]')!;
|
|
68
|
-
const previous = pagination.querySelector('[data-paginate="previous"]')!;
|
|
69
|
-
const first = pagination.querySelector('[data-paginate="first"]')!;
|
|
70
|
-
const last = pagination.querySelector('[data-paginate="last"]')!;
|
|
71
|
-
const pageSizeSelect = pagination.querySelector(".page-size-select")!;
|
|
72
|
-
const currentPageInput = pagination.querySelector("#current-value-input")!;
|
|
73
|
-
|
|
74
|
-
await userEvent.click(next);
|
|
75
|
-
|
|
76
|
-
await waitFor(() => expect(onPageChange).toHaveBeenCalledWith(11));
|
|
77
|
-
|
|
78
|
-
await userEvent.click(previous);
|
|
79
|
-
await waitFor(() => expect(onPageChange).toHaveBeenCalledWith(9));
|
|
80
|
-
|
|
81
|
-
await userEvent.click(first);
|
|
82
|
-
await waitFor(() => expect(onPageChange).toHaveBeenCalledWith(1));
|
|
83
|
-
|
|
84
|
-
await userEvent.click(last);
|
|
85
|
-
await waitFor(() => expect(onPageChange).toHaveBeenCalledWith(50));
|
|
86
|
-
|
|
87
|
-
await userEvent.click(pageSizeSelect.querySelector("button")!);
|
|
88
|
-
|
|
89
|
-
const option25 = pageSizeSelect.querySelector('[data-value="25"]')!;
|
|
90
|
-
|
|
91
|
-
await userEvent.click(option25);
|
|
92
|
-
|
|
93
|
-
await waitFor(() => expect(onPageSizeChange).toHaveBeenCalledWith(25));
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe("different current pages and their effect on what renders", () => {
|
|
98
|
-
it("is on the first page and does not render previous and first", () => {
|
|
99
|
-
const { pagination } = createPagination();
|
|
100
|
-
|
|
101
|
-
expect(pagination.querySelector('[data-paginate="next"]')).toBeTruthy();
|
|
102
|
-
expect(pagination.querySelector('[data-paginate="previous"]')).toHaveAttribute("disabled");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("is on the second page and does render first", async () => {
|
|
106
|
-
const { pagination } = createPagination(defaultParams => ({
|
|
107
|
-
...defaultParams,
|
|
108
|
-
currentPage: 2
|
|
109
|
-
}));
|
|
110
|
-
|
|
111
|
-
expect(pagination.querySelector('[data-paginate="first"]')).not.toHaveAttribute("disabled");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("is on the second to last page and does render last", () => {
|
|
115
|
-
const { pagination } = createPagination(defaultParams => ({
|
|
116
|
-
...defaultParams,
|
|
117
|
-
currentPage: 49
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
expect(pagination.querySelector('[data-paginate="last"]')).not.toHaveAttribute("disabled");
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("is on the last page and does not render next & last", () => {
|
|
124
|
-
const { pagination } = createPagination(defaultParams => ({
|
|
125
|
-
...defaultParams,
|
|
126
|
-
currentPage: 50
|
|
127
|
-
}));
|
|
128
|
-
|
|
129
|
-
expect(pagination.querySelector('[data-paginate="last"]')).toHaveAttribute("disabled");
|
|
130
|
-
expect(pagination.querySelector('[data-paginate="next"]')).toHaveAttribute("disabled");
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe("omitted attributes still renders correctly", () => {
|
|
135
|
-
it("still renders next if totalItems prop isn't given and we're on the first page", () => {
|
|
136
|
-
const { pagination } = createPagination(defaultParams => ({
|
|
137
|
-
...defaultParams,
|
|
138
|
-
totalElements: undefined
|
|
139
|
-
}));
|
|
140
|
-
|
|
141
|
-
expect(pagination.querySelector(".page")).toBeFalsy();
|
|
142
|
-
expect(pagination.querySelector('[data-paginate="next"]')).toBeTruthy();
|
|
143
|
-
expect(pagination.querySelector('[data-paginate="previous"]')).toHaveAttribute("disabled");
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("still renders next if totalItems prop isn't given and we're on the first page", () => {
|
|
147
|
-
const { pagination } = createPagination(defaultParams => ({
|
|
148
|
-
...defaultParams,
|
|
149
|
-
currentPage: 4,
|
|
150
|
-
totalElements: undefined
|
|
151
|
-
}));
|
|
152
|
-
|
|
153
|
-
expect(pagination.querySelector(".page")).toBeFalsy();
|
|
154
|
-
expect(pagination.querySelector('[data-paginate="next"]')).toBeTruthy();
|
|
155
|
-
expect(pagination.querySelector('[data-paginate="previous"]')).toBeTruthy();
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe("ref should work", () => {
|
|
160
|
-
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
161
|
-
const ExampleComponent = ({
|
|
162
|
-
propagateRef
|
|
163
|
-
}: {
|
|
164
|
-
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
165
|
-
}) => {
|
|
166
|
-
const ref = useRef(null);
|
|
167
|
-
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
if (ref.current) {
|
|
170
|
-
propagateRef && propagateRef(ref);
|
|
171
|
-
}
|
|
172
|
-
}, [ref]);
|
|
173
|
-
|
|
174
|
-
return <Pagination {...defaultParams} data-ref="testing" ref={ref} />;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
178
|
-
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
render(<ExampleComponent propagateRef={refCheck} />);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
@@ -1,103 +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, { Fragment, useRef } from "react";
|
|
18
|
-
import { Popover, Props } from "./Popover";
|
|
19
|
-
import { render } from "@testing-library/react";
|
|
20
|
-
import { usePosition } from "../../hooks/usePosition";
|
|
21
|
-
|
|
22
|
-
const createPopover = (params?: (defaultParams: Props) => Props) => {
|
|
23
|
-
const Component = () => {
|
|
24
|
-
const relativeElement = useRef<HTMLButtonElement>(null);
|
|
25
|
-
const elementToBePositioned = useRef<HTMLDivElement>(null);
|
|
26
|
-
|
|
27
|
-
const defaultParams: Props = {
|
|
28
|
-
children: (
|
|
29
|
-
<ul>
|
|
30
|
-
<li>Test</li>
|
|
31
|
-
<li>Test</li>
|
|
32
|
-
<li>Test</li>
|
|
33
|
-
</ul>
|
|
34
|
-
),
|
|
35
|
-
show: true,
|
|
36
|
-
placement: { vertical: "top", horizontal: "left" }
|
|
37
|
-
};
|
|
38
|
-
let parameters: Props = defaultParams;
|
|
39
|
-
|
|
40
|
-
if (params) {
|
|
41
|
-
parameters = params(defaultParams);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const { top, left, bottom, right, calculatePosition } = usePosition({
|
|
45
|
-
elementToBePositioned: elementToBePositioned,
|
|
46
|
-
relativeElement: relativeElement,
|
|
47
|
-
...parameters
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Fragment>
|
|
52
|
-
<button data-testid="button" onClick={calculatePosition} ref={relativeElement}>
|
|
53
|
-
Test
|
|
54
|
-
</button>
|
|
55
|
-
<Popover
|
|
56
|
-
{...defaultParams}
|
|
57
|
-
data-testid="popover"
|
|
58
|
-
style={{ top: top, left: left, bottom: bottom, right: right }}
|
|
59
|
-
ref={elementToBePositioned}
|
|
60
|
-
>
|
|
61
|
-
Test
|
|
62
|
-
</Popover>
|
|
63
|
-
</Fragment>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const queries = render(<Component />);
|
|
68
|
-
const button = queries.getByTestId("button");
|
|
69
|
-
const popover = queries.getByTestId("popover");
|
|
70
|
-
|
|
71
|
-
/** Let the hacking begin */
|
|
72
|
-
Object.defineProperty(button, "offsetHeight", { configurable: true, value: 500 });
|
|
73
|
-
Object.defineProperty(button, "offsetWidth", { configurable: true, value: 500 });
|
|
74
|
-
|
|
75
|
-
Object.defineProperty(window, "innerHeight", {
|
|
76
|
-
configurable: true,
|
|
77
|
-
value: 1000
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(window, "innerWidth", {
|
|
80
|
-
configurable: true,
|
|
81
|
-
value: 1000
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
Object.defineProperty(popover, "offsetHeight", { configurable: true, value: 100 });
|
|
85
|
-
Object.defineProperty(popover, "offsetWidth", { configurable: true, value: 100 });
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
...queries,
|
|
89
|
-
popover,
|
|
90
|
-
button
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
describe("Popover should render", () => {
|
|
95
|
-
it("renders without crashing and has default left and top attributes", () => {
|
|
96
|
-
const { popover } = createPopover();
|
|
97
|
-
|
|
98
|
-
window.dispatchEvent(new Event("resize"));
|
|
99
|
-
window.dispatchEvent(new Event("scroll"));
|
|
100
|
-
|
|
101
|
-
expect(popover).toBeTruthy();
|
|
102
|
-
});
|
|
103
|
-
});
|