@onewelcome/react-lib-components 1.9.1 → 2.0.0-alpha
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/_BaseStyling_/BaseStyling.d.ts +4 -3
- package/dist/react-lib-components.cjs.development.js +7 -6
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +7 -6
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +16 -16
- package/src/Form/FileUpload/FileItem/FileItem.modules.scss +1 -1
- package/src/Form/FileUpload/FileUpload.module.scss +1 -1
- package/src/Form/FileUpload/FileUpload.tsx +3 -1
- package/src/Form/Select/Select.test.tsx +66 -22
- package/src/Tabs/Tabs.test.tsx +1 -1
- package/src/Tiles/Tile.test.tsx +10 -4
- package/src/Tooltip/Tooltip.test.tsx +5 -3
- package/src/_BaseStyling_/BaseStyling.tsx +11 -9
- package/src/hooks/useAnimation.test.tsx +8 -2
- package/src/util/helper.test.tsx +33 -22
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"homepage": "http://onewelcome.github.io/react-lib-components",
|
|
3
3
|
"name": "@onewelcome/react-lib-components",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-alpha",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "OneWelcome B.V.",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/core": "^7.21.
|
|
56
|
+
"@babel/core": "^7.21.4",
|
|
57
57
|
"@mdx-js/react": "^1.6.22",
|
|
58
58
|
"@onewelcome/eslint-config-shared-codestyle": "^9.0.3",
|
|
59
59
|
"@size-limit/preset-small-lib": "^8.2.4",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@storybook/preset-scss": "^1.0.3",
|
|
68
68
|
"@storybook/react": "^6.5.16",
|
|
69
69
|
"@storybook/theming": "^6.5.16",
|
|
70
|
-
"@testing-library/dom": "^
|
|
70
|
+
"@testing-library/dom": "^9.2.0",
|
|
71
71
|
"@testing-library/jest-dom": "^5.16.5",
|
|
72
72
|
"@testing-library/react": "^12.1.5",
|
|
73
73
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -75,37 +75,37 @@
|
|
|
75
75
|
"@tsconfig/create-react-app": "^1.0.3",
|
|
76
76
|
"@tsconfig/recommended": "^1.0.2",
|
|
77
77
|
"@types/color-convert": "^2.0.0",
|
|
78
|
-
"@types/mdx": "^2.0.
|
|
78
|
+
"@types/mdx": "^2.0.4",
|
|
79
79
|
"@types/react": "^17.0.52",
|
|
80
80
|
"@types/react-dom": "^17.0.18",
|
|
81
81
|
"@types/react-router": "^5.1.20",
|
|
82
82
|
"@types/react-router-dom": "^5.3.3",
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
84
|
-
"@typescript-eslint/parser": "^5.
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
|
84
|
+
"@typescript-eslint/parser": "^5.59.1",
|
|
85
85
|
"babel-loader": "^9.1.2",
|
|
86
|
-
"chromatic": "^6.17.
|
|
86
|
+
"chromatic": "^6.17.3",
|
|
87
87
|
"dts-cli": "^1.6.3",
|
|
88
|
-
"eslint": "^8.
|
|
88
|
+
"eslint": "^8.39.0",
|
|
89
89
|
"eslint-config-prettier": "^8.8.0",
|
|
90
|
-
"eslint-plugin-cypress": "^2.
|
|
90
|
+
"eslint-plugin-cypress": "^2.13.2",
|
|
91
91
|
"eslint-plugin-jest": "^27.2.1",
|
|
92
92
|
"eslint-plugin-license-header": "^0.6.0",
|
|
93
93
|
"eslint-plugin-prettier": "^4.2.1",
|
|
94
|
-
"html-webpack-plugin": "^5.5.
|
|
94
|
+
"html-webpack-plugin": "^5.5.1",
|
|
95
95
|
"husky": "^8.0.3",
|
|
96
96
|
"identity-obj-proxy": "^3.0.0",
|
|
97
|
-
"jest-junit": "^
|
|
98
|
-
"lint-staged": "^13.2.
|
|
97
|
+
"jest-junit": "^16.0.0",
|
|
98
|
+
"lint-staged": "^13.2.1",
|
|
99
99
|
"npm-run-all": "^4.1.5",
|
|
100
|
-
"prettier": "^2.8.
|
|
100
|
+
"prettier": "^2.8.8",
|
|
101
101
|
"react": "^17.0.2",
|
|
102
102
|
"react-dom": "^17.0.2",
|
|
103
103
|
"react-is": "^18.2.0",
|
|
104
|
-
"react-router": "^6.
|
|
105
|
-
"react-router-dom": "^6.
|
|
104
|
+
"react-router": "^6.10.0",
|
|
105
|
+
"react-router-dom": "^6.10.0",
|
|
106
106
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
107
107
|
"rollup-plugin-styles": "^4.0.0",
|
|
108
|
-
"sass": "^1.
|
|
108
|
+
"sass": "^1.62.1",
|
|
109
109
|
"size-limit": "^8.2.4",
|
|
110
110
|
"style-loader": "^3.3.2",
|
|
111
111
|
"tslib": "^2.5.0",
|
|
@@ -157,7 +157,9 @@ const FileUploadComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
|
|
|
157
157
|
const handleOnDragOver = (e: DragEvent<HTMLDivElement>) => {
|
|
158
158
|
e.preventDefault();
|
|
159
159
|
e.stopPropagation();
|
|
160
|
-
|
|
160
|
+
if (!dragActive) {
|
|
161
|
+
setDragActive(true);
|
|
162
|
+
}
|
|
161
163
|
onDragOver && onDragOver(e);
|
|
162
164
|
};
|
|
163
165
|
|
|
@@ -19,6 +19,7 @@ import { Select as SelectComponent, Props } from "./Select";
|
|
|
19
19
|
import { render, waitFor } from "@testing-library/react";
|
|
20
20
|
import { Option } from "./Option";
|
|
21
21
|
import userEvent from "@testing-library/user-event";
|
|
22
|
+
import { act } from "react-dom/test-utils";
|
|
22
23
|
|
|
23
24
|
const defaultParams: Props = {
|
|
24
25
|
name: "Example select",
|
|
@@ -85,7 +86,9 @@ describe("Select should render", () => {
|
|
|
85
86
|
expect(dropdownWrapper).toHaveStyle({ "pointer-events": "none" });
|
|
86
87
|
|
|
87
88
|
if (button) {
|
|
88
|
-
|
|
89
|
+
act(() => {
|
|
90
|
+
userEvent.click(button);
|
|
91
|
+
});
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
expect(select).toBeDefined();
|
|
@@ -165,7 +168,9 @@ describe("Select should render with search", () => {
|
|
|
165
168
|
const searchInput = getByTestId("search-input");
|
|
166
169
|
|
|
167
170
|
if (button) {
|
|
168
|
-
|
|
171
|
+
act(() => {
|
|
172
|
+
userEvent.click(button);
|
|
173
|
+
});
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
expect(select).toBeTruthy();
|
|
@@ -189,7 +194,9 @@ describe("Selecting options using keyboard", () => {
|
|
|
189
194
|
onChange: onChangeHandler
|
|
190
195
|
}));
|
|
191
196
|
|
|
192
|
-
|
|
197
|
+
act(() => {
|
|
198
|
+
userEvent.click(button);
|
|
199
|
+
});
|
|
193
200
|
|
|
194
201
|
expect(button).toHaveAttribute("aria-expanded", "true");
|
|
195
202
|
|
|
@@ -235,11 +242,15 @@ describe("Expanded should be false whenever we click the body", () => {
|
|
|
235
242
|
const { button } = createSelect();
|
|
236
243
|
|
|
237
244
|
if (button) {
|
|
238
|
-
|
|
245
|
+
act(() => {
|
|
246
|
+
userEvent.click(button);
|
|
247
|
+
});
|
|
239
248
|
}
|
|
240
249
|
|
|
241
250
|
expect(button).toHaveAttribute("aria-expanded", "true");
|
|
242
|
-
|
|
251
|
+
act(() => {
|
|
252
|
+
userEvent.click(document.body);
|
|
253
|
+
});
|
|
243
254
|
expect(button).toHaveAttribute("aria-expanded", "false");
|
|
244
255
|
});
|
|
245
256
|
});
|
|
@@ -263,7 +274,9 @@ describe("List expansion", () => {
|
|
|
263
274
|
});
|
|
264
275
|
|
|
265
276
|
if (button) {
|
|
266
|
-
|
|
277
|
+
act(() => {
|
|
278
|
+
userEvent.click(button);
|
|
279
|
+
});
|
|
267
280
|
}
|
|
268
281
|
|
|
269
282
|
expect(dropdownWrapper).toHaveStyle({ bottom: "0px" });
|
|
@@ -298,9 +311,14 @@ describe("List expansion", () => {
|
|
|
298
311
|
toJSON: () => jest.fn()
|
|
299
312
|
});
|
|
300
313
|
|
|
301
|
-
|
|
314
|
+
act(() => {
|
|
315
|
+
userEvent.click(document.body);
|
|
316
|
+
});
|
|
317
|
+
|
|
302
318
|
const button = getByRole("button");
|
|
303
|
-
|
|
319
|
+
act(() => {
|
|
320
|
+
userEvent.click(button);
|
|
321
|
+
});
|
|
304
322
|
|
|
305
323
|
expect(dropdownWrapper).toHaveStyle({ maxHeight: "474px" });
|
|
306
324
|
expect(dropdownWrapper).toHaveStyle({ top: "0px" });
|
|
@@ -308,59 +326,73 @@ describe("List expansion", () => {
|
|
|
308
326
|
});
|
|
309
327
|
|
|
310
328
|
describe("previously selected item", () => {
|
|
311
|
-
it("should have focus", () => {
|
|
329
|
+
it("should have focus", async () => {
|
|
312
330
|
const { select, button } = createSelect(defaultParams => ({
|
|
313
331
|
...defaultParams,
|
|
314
332
|
value: "option4"
|
|
315
333
|
}));
|
|
316
334
|
|
|
317
|
-
|
|
335
|
+
await act(async () => {
|
|
336
|
+
button.focus();
|
|
337
|
+
});
|
|
318
338
|
|
|
319
339
|
const option2 = select.querySelector('li[data-value="option2"]')!;
|
|
320
340
|
|
|
321
341
|
userEvent.keyboard("{enter}");
|
|
342
|
+
|
|
322
343
|
expect(button).toHaveAttribute("aria-expanded", "true");
|
|
323
344
|
userEvent.keyboard("{arrowdown}");
|
|
324
345
|
userEvent.keyboard("{arrowdown}");
|
|
325
346
|
userEvent.keyboard("{space}");
|
|
326
347
|
|
|
327
|
-
|
|
348
|
+
act(() => {
|
|
349
|
+
userEvent.click(button);
|
|
350
|
+
});
|
|
328
351
|
|
|
329
352
|
expect(document.activeElement).toBe(option2);
|
|
330
353
|
});
|
|
331
354
|
});
|
|
332
355
|
|
|
333
356
|
describe("search input", () => {
|
|
334
|
-
it("listens to different keyboard inputs",
|
|
357
|
+
it("listens to different keyboard inputs", () => {
|
|
335
358
|
const { button, select } = createSelect();
|
|
336
359
|
|
|
337
360
|
const searchInput = document.querySelector(".select-search")!;
|
|
338
361
|
|
|
339
|
-
|
|
362
|
+
act(() => {
|
|
363
|
+
userEvent.click(button);
|
|
364
|
+
});
|
|
365
|
+
|
|
340
366
|
(searchInput as HTMLElement).focus();
|
|
341
367
|
|
|
342
368
|
userEvent.keyboard("{arrowup}");
|
|
343
369
|
expect(select.querySelector('li[data-value="option17"]')).toHaveFocus();
|
|
344
370
|
});
|
|
345
371
|
|
|
346
|
-
it("move focus with arrowdown",
|
|
372
|
+
it("move focus with arrowdown", () => {
|
|
347
373
|
const { button, select } = createSelect();
|
|
348
374
|
|
|
349
375
|
const searchInput = document.querySelector(".select-search")!;
|
|
350
376
|
|
|
351
|
-
|
|
377
|
+
act(() => {
|
|
378
|
+
userEvent.click(button);
|
|
379
|
+
});
|
|
380
|
+
|
|
352
381
|
(searchInput as HTMLElement).focus();
|
|
353
382
|
|
|
354
383
|
userEvent.keyboard("{arrowdown}");
|
|
355
384
|
expect(select.querySelector('li[data-value="option1"]')).toHaveFocus();
|
|
356
385
|
});
|
|
357
386
|
|
|
358
|
-
it("select with enter",
|
|
387
|
+
it("select with enter", () => {
|
|
359
388
|
const { button, select } = createSelect();
|
|
360
389
|
|
|
361
390
|
const searchInput = document.querySelector(".select-search")!;
|
|
362
391
|
|
|
363
|
-
|
|
392
|
+
act(() => {
|
|
393
|
+
userEvent.click(button);
|
|
394
|
+
});
|
|
395
|
+
|
|
364
396
|
(searchInput as HTMLElement).focus();
|
|
365
397
|
|
|
366
398
|
userEvent.keyboard("{enter}");
|
|
@@ -390,7 +422,10 @@ describe("search input", () => {
|
|
|
390
422
|
|
|
391
423
|
const searchInput = document.querySelector(".select-search")!;
|
|
392
424
|
|
|
393
|
-
|
|
425
|
+
act(() => {
|
|
426
|
+
userEvent.click(button);
|
|
427
|
+
});
|
|
428
|
+
|
|
394
429
|
userEvent.tab();
|
|
395
430
|
|
|
396
431
|
await waitFor(() => expect(searchInput).toHaveFocus());
|
|
@@ -405,10 +440,17 @@ describe("search input", () => {
|
|
|
405
440
|
|
|
406
441
|
const searchInput = document.querySelector(".select-search")!;
|
|
407
442
|
|
|
408
|
-
|
|
443
|
+
act(() => {
|
|
444
|
+
userEvent.click(button);
|
|
445
|
+
});
|
|
446
|
+
|
|
409
447
|
userEvent.tab();
|
|
448
|
+
|
|
410
449
|
expect(searchInput).toHaveFocus();
|
|
411
|
-
|
|
450
|
+
|
|
451
|
+
act(() => {
|
|
452
|
+
userEvent.tab();
|
|
453
|
+
});
|
|
412
454
|
});
|
|
413
455
|
});
|
|
414
456
|
|
|
@@ -416,14 +458,16 @@ describe("home and end keys work", () => {
|
|
|
416
458
|
it("goes to home and end", () => {
|
|
417
459
|
const { button } = createSelect();
|
|
418
460
|
|
|
419
|
-
|
|
461
|
+
act(() => {
|
|
462
|
+
userEvent.click(button);
|
|
463
|
+
});
|
|
420
464
|
|
|
421
465
|
const firstOption = document.querySelector('li[data-value="option1"]');
|
|
422
466
|
const lastOption = document.querySelector('li[data-value="option17"]');
|
|
423
|
-
|
|
424
467
|
userEvent.keyboard("{end}");
|
|
425
468
|
|
|
426
469
|
expect(lastOption).toHaveFocus();
|
|
470
|
+
|
|
427
471
|
userEvent.keyboard("{home}");
|
|
428
472
|
|
|
429
473
|
expect(firstOption).toHaveFocus();
|
package/src/Tabs/Tabs.test.tsx
CHANGED
|
@@ -109,7 +109,7 @@ describe("Tabs should render", () => {
|
|
|
109
109
|
expect(tabpanel1).toHaveClass("selected");
|
|
110
110
|
expect(tabpanel3).not.toHaveClass("selected");
|
|
111
111
|
|
|
112
|
-
await userEvent.click(tab3);
|
|
112
|
+
await act(() => userEvent.click(tab3));
|
|
113
113
|
|
|
114
114
|
tabButtons = tablist.querySelectorAll(".tabbutton");
|
|
115
115
|
|
package/src/Tiles/Tile.test.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import { ContextMenu } from "../ContextMenu/ContextMenu";
|
|
|
22
22
|
import { IconButton } from "../Button/IconButton";
|
|
23
23
|
import { ContextMenuItem } from "../ContextMenu/ContextMenuItem";
|
|
24
24
|
import userEvent from "@testing-library/user-event";
|
|
25
|
+
import { act } from "react-dom/test-utils";
|
|
25
26
|
|
|
26
27
|
const onShow = jest.fn();
|
|
27
28
|
const onClose = jest.fn();
|
|
@@ -141,14 +142,19 @@ describe("contextmenu", () => {
|
|
|
141
142
|
expect(menuitem2).toBeTruthy();
|
|
142
143
|
expect(menuitem3).toBeTruthy();
|
|
143
144
|
|
|
144
|
-
|
|
145
|
+
act(() => {
|
|
146
|
+
userEvent.click(menutrigger);
|
|
147
|
+
});
|
|
148
|
+
|
|
145
149
|
expect(onShow).toHaveBeenCalled();
|
|
146
150
|
expect(popover).toHaveClass("show");
|
|
147
151
|
expect(popover).toHaveStyle({ opacity: "1;" });
|
|
148
152
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
act(() => {
|
|
154
|
+
userEvent.click(menuitem1);
|
|
155
|
+
userEvent.click(menuitem2);
|
|
156
|
+
userEvent.click(menuitem3);
|
|
157
|
+
});
|
|
152
158
|
|
|
153
159
|
expect(contextMenuItemOnClick).toHaveBeenCalledTimes(3);
|
|
154
160
|
});
|
|
@@ -80,7 +80,7 @@ describe("Tooltip should render", () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
describe("It opens the tooltip", () => {
|
|
83
|
-
it("opens", () => {
|
|
83
|
+
it("opens", async () => {
|
|
84
84
|
const { tooltip, getByText } = createTooltip();
|
|
85
85
|
|
|
86
86
|
const icon = tooltip.querySelector(".icon")!;
|
|
@@ -92,8 +92,10 @@ describe("It opens the tooltip", () => {
|
|
|
92
92
|
|
|
93
93
|
userEvent.keyboard("{escape}");
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
await waitFor(() => {
|
|
96
|
+
expect(tooltipHover).not.toHaveClass("visible");
|
|
97
|
+
expect(tooltipHover).toHaveAttribute("aria-hidden", "true");
|
|
98
|
+
});
|
|
97
99
|
});
|
|
98
100
|
});
|
|
99
101
|
|
|
@@ -22,12 +22,11 @@
|
|
|
22
22
|
import React, { HTMLAttributes, ReactChild, useEffect, useRef, useState } from "react";
|
|
23
23
|
|
|
24
24
|
interface CSSProperties {
|
|
25
|
+
colorBlack10?: string;
|
|
25
26
|
colorFocus?: string;
|
|
26
27
|
colorPrimary?: string;
|
|
27
28
|
colorSecondary?: string;
|
|
28
29
|
colorTertiary?: string;
|
|
29
|
-
lightPink?: string;
|
|
30
|
-
vividViolet?: string;
|
|
31
30
|
colorPrimary300?: string;
|
|
32
31
|
colorPrimary500?: string;
|
|
33
32
|
colorPrimary600?: string;
|
|
@@ -37,6 +36,8 @@ interface CSSProperties {
|
|
|
37
36
|
colorBlueGrey200?: string;
|
|
38
37
|
colorBlueGrey400?: string;
|
|
39
38
|
colorBlueGrey25?: string;
|
|
39
|
+
colorBlueGrey25Transparent?: string;
|
|
40
|
+
colorBlueGrey50?: string;
|
|
40
41
|
colorBlueGrey500?: string;
|
|
41
42
|
colorBlueGrey700?: string;
|
|
42
43
|
colorBlueGrey900?: string;
|
|
@@ -45,6 +46,7 @@ interface CSSProperties {
|
|
|
45
46
|
colorLightBlue600?: string;
|
|
46
47
|
colorOrange500?: string;
|
|
47
48
|
colorRed500?: string;
|
|
49
|
+
colorWhite?: string;
|
|
48
50
|
defaultLineHeight?: string;
|
|
49
51
|
buttonBorderRadius?: string;
|
|
50
52
|
buttonBorderWidth?: string;
|
|
@@ -91,7 +93,6 @@ interface CSSProperties {
|
|
|
91
93
|
lightGreyBorder?: string;
|
|
92
94
|
warning?: string;
|
|
93
95
|
light?: string;
|
|
94
|
-
grey?: string;
|
|
95
96
|
fontFamily?: string;
|
|
96
97
|
fontFamilyCode?: string;
|
|
97
98
|
fontSize?: string;
|
|
@@ -110,12 +111,15 @@ export interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
|
110
111
|
|
|
111
112
|
export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
112
113
|
const defaultProperties: CSSProperties = {
|
|
114
|
+
colorBlack10: "#0000001a",
|
|
113
115
|
colorPrimary300: "#6871BF",
|
|
114
116
|
colorPrimary500: "#041295",
|
|
115
117
|
colorPrimary600: "#030F77",
|
|
116
118
|
colorPrimary700: "#020B59",
|
|
117
119
|
colorPrimary900: "#01041E",
|
|
118
120
|
colorBlueGrey25: "#F7F7F9",
|
|
121
|
+
colorBlueGrey25Transparent: "#F7F7F980",
|
|
122
|
+
colorBlueGrey50: "#EEEFF3",
|
|
119
123
|
colorBlueGrey100: "#DEDEE6",
|
|
120
124
|
colorBlueGrey200: "#BCBECE",
|
|
121
125
|
colorBlueGrey400: "#797D9C",
|
|
@@ -127,12 +131,11 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
|
127
131
|
colorLightBlue600: "#0096B1",
|
|
128
132
|
colorOrange500: "#E07900",
|
|
129
133
|
colorRed500: "#E01E00",
|
|
134
|
+
colorWhite: "#FFFFFF",
|
|
130
135
|
colorFocus: "var(--color-primary300)",
|
|
131
136
|
colorPrimary: "var(--color-primary500)",
|
|
132
137
|
colorSecondary: "var(--color-blue-grey700)",
|
|
133
138
|
colorTertiary: "var(--color-light-blue600)",
|
|
134
|
-
lightPink: "#9E006B1A",
|
|
135
|
-
vividViolet: "#9E006B",
|
|
136
139
|
defaultLineHeight: "1.5",
|
|
137
140
|
buttonBorderRadius: "2px",
|
|
138
141
|
buttonBorderWidth: "2px",
|
|
@@ -146,8 +149,8 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
|
146
149
|
inputBorderWidthFocus: "2px",
|
|
147
150
|
inputBorderStyle: "solid",
|
|
148
151
|
inputBackgroundColor: "var(--light)",
|
|
149
|
-
dragBackgroundColor: "
|
|
150
|
-
dragBorderStyle: "
|
|
152
|
+
dragBackgroundColor: "var(--color-blue-grey25-transparent)",
|
|
153
|
+
dragBorderStyle: "solid",
|
|
151
154
|
modalShadowColor: "rgba(0, 0, 0, 0.16)",
|
|
152
155
|
modalBackgroundColor: "var(--color-blue-grey25)",
|
|
153
156
|
modalHeaderBackgroundColor: "var(--light)",
|
|
@@ -178,8 +181,7 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
|
|
|
178
181
|
greyedOut: "var(--color-blue-grey500)",
|
|
179
182
|
lightGreyBorder: "var(--color-blue-grey100)",
|
|
180
183
|
warning: "var(--color-orange500)",
|
|
181
|
-
light: "
|
|
182
|
-
grey: "#c3c3c7",
|
|
184
|
+
light: "var(--color-white)",
|
|
183
185
|
fontFamily: "Roboto, sans-serif",
|
|
184
186
|
fontFamilyCode: "'Roboto Mono', monospace",
|
|
185
187
|
fontSize: "1rem",
|
|
@@ -18,6 +18,7 @@ import React, { Fragment } from "react";
|
|
|
18
18
|
import { render, fireEvent } from "@testing-library/react";
|
|
19
19
|
import userEvent from "@testing-library/user-event";
|
|
20
20
|
import { useAnimation } from "./useAnimation";
|
|
21
|
+
import { act } from "react-dom/test-utils";
|
|
21
22
|
|
|
22
23
|
describe("useAnimation", () => {
|
|
23
24
|
it("should execute", () => {
|
|
@@ -49,12 +50,17 @@ describe("useAnimation", () => {
|
|
|
49
50
|
|
|
50
51
|
expect(animatedDiv).not.toHaveClass("animation-started");
|
|
51
52
|
expect(callback).not.toBeCalled();
|
|
53
|
+
act(() => {
|
|
54
|
+
userEvent.click(startButton);
|
|
55
|
+
});
|
|
52
56
|
|
|
53
|
-
userEvent.click(startButton);
|
|
54
57
|
expect(animatedDiv).toHaveClass("animation-started");
|
|
55
58
|
expect(callback).not.toBeCalled();
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
act(() => {
|
|
61
|
+
fireEvent.animationEnd(animatedDiv);
|
|
62
|
+
});
|
|
63
|
+
|
|
58
64
|
expect(animatedDiv).toHaveClass("animation-started");
|
|
59
65
|
expect(callback).toBeCalled();
|
|
60
66
|
});
|
package/src/util/helper.test.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
isJsonString
|
|
29
29
|
} from "./helper";
|
|
30
30
|
import { render } from "@testing-library/react";
|
|
31
|
+
import { act } from "react-dom/test-utils";
|
|
31
32
|
|
|
32
33
|
/* Generate an ID of 20 characters with a string woven in */
|
|
33
34
|
|
|
@@ -86,11 +87,13 @@ describe("debounce function", () => {
|
|
|
86
87
|
|
|
87
88
|
window.addEventListener("resize", debounce(debouncedFunction, 200));
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
act(() => {
|
|
91
|
+
fireEvent.resize(window);
|
|
92
|
+
fireEvent.resize(window);
|
|
93
|
+
fireEvent.resize(window);
|
|
94
|
+
fireEvent.resize(window);
|
|
95
|
+
fireEvent.resize(window);
|
|
96
|
+
});
|
|
94
97
|
|
|
95
98
|
await waitFor(() => expect(debouncedFunction).toHaveBeenCalledTimes(1));
|
|
96
99
|
});
|
|
@@ -108,7 +111,9 @@ describe("debounce function", () => {
|
|
|
108
111
|
}, [variable]);
|
|
109
112
|
|
|
110
113
|
const incrementVariable = () => {
|
|
111
|
-
|
|
114
|
+
act(() => {
|
|
115
|
+
setVariable(Math.random());
|
|
116
|
+
});
|
|
112
117
|
};
|
|
113
118
|
|
|
114
119
|
useEffect(() => {
|
|
@@ -122,11 +127,13 @@ describe("debounce function", () => {
|
|
|
122
127
|
|
|
123
128
|
render(<ExampleComponent debouncedFunction={exampleFunction} />);
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
act(() => {
|
|
131
|
+
fireEvent.resize(window);
|
|
132
|
+
fireEvent.resize(window);
|
|
133
|
+
fireEvent.resize(window);
|
|
134
|
+
fireEvent.resize(window);
|
|
135
|
+
fireEvent.resize(window);
|
|
136
|
+
});
|
|
130
137
|
|
|
131
138
|
expect(exampleFunction).toHaveBeenCalledTimes(1);
|
|
132
139
|
});
|
|
@@ -146,7 +153,9 @@ describe("throttling works", () => {
|
|
|
146
153
|
}, [variable]);
|
|
147
154
|
|
|
148
155
|
const incrementVariable = useCallback(() => {
|
|
149
|
-
|
|
156
|
+
act(() => {
|
|
157
|
+
setVariable(Math.random());
|
|
158
|
+
});
|
|
150
159
|
}, []);
|
|
151
160
|
|
|
152
161
|
useEffect(() => {
|
|
@@ -160,16 +169,18 @@ describe("throttling works", () => {
|
|
|
160
169
|
|
|
161
170
|
render(<ExampleComponent throttledFunction={exampleFunction} />);
|
|
162
171
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
act(() => {
|
|
173
|
+
fireEvent.resize(window);
|
|
174
|
+
fireEvent.resize(window);
|
|
175
|
+
fireEvent.resize(window);
|
|
176
|
+
fireEvent.resize(window);
|
|
177
|
+
fireEvent.resize(window);
|
|
178
|
+
fireEvent.resize(window);
|
|
179
|
+
fireEvent.resize(window);
|
|
180
|
+
fireEvent.resize(window);
|
|
181
|
+
fireEvent.resize(window);
|
|
182
|
+
fireEvent.resize(window);
|
|
183
|
+
});
|
|
173
184
|
|
|
174
185
|
expect(exampleFunction).not.toHaveBeenCalledTimes(1);
|
|
175
186
|
expect(exampleFunction).not.toHaveBeenCalledTimes(10);
|