@transferwise/components 0.0.0-experimental-40b5678 → 0.0.0-experimental-6ad430a
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/package.json +8 -7
- package/src/accordion/Accordion.spec.js +5 -5
- package/src/accordion/AccordionItem/AccordionItem.spec.js +2 -2
- package/src/actionButton/ActionButton.spec.tsx +5 -4
- package/src/alert/Alert.spec.tsx +4 -4
- package/src/button/Button.spec.js +5 -4
- package/src/card/Card.spec.tsx +4 -4
- package/src/carousel/Carousel.spec.tsx +17 -17
- package/src/checkbox/Checkbox.spec.tsx +2 -0
- package/src/checkboxButton/CheckboxButton.spec.tsx +2 -0
- package/src/checkboxOption/CheckboxOption.spec.tsx +2 -0
- package/src/chevron/Chevron.spec.tsx +1 -0
- package/src/chips/Chips.spec.tsx +1 -0
- package/src/circularButton/CircularButton.spec.tsx +5 -4
- package/src/common/RadioButton/RadioButton.spec.tsx +2 -2
- package/src/common/closeButton/CloseButton.spec.tsx +1 -0
- package/src/common/flowHeader/FlowHeader.spec.tsx +1 -0
- package/src/dateLookup/DateLookup.rtl.spec.tsx +16 -18
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +44 -47
- package/src/decision/Decision.spec.js +2 -0
- package/src/dimmer/Dimmer.rtl.spec.js +10 -10
- package/src/drawer/Drawer.rtl.spec.tsx +2 -2
- package/src/emphasis/Emphasis.spec.tsx +1 -0
- package/src/field/Field.spec.tsx +2 -2
- package/src/flowNavigation/FlowNavigation.spec.js +2 -0
- package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +1 -0
- package/src/header/Header.spec.tsx +6 -6
- package/src/image/Image.spec.tsx +1 -0
- package/src/inlineAlert/InlineAlert.spec.tsx +1 -0
- package/src/inputs/SelectInput.spec.tsx +47 -26
- package/src/link/Link.spec.tsx +1 -0
- package/src/listItem/ListItem.spec.tsx +1 -0
- package/src/moneyInput/MoneyInput.rtl.spec.tsx +2 -2
- package/src/popover/Popover.spec.tsx +10 -10
- package/src/progress/Progress.spec.tsx +1 -0
- package/src/progressBar/ProgressBar.spec.tsx +1 -0
- package/src/segmentedControl/SegmentedControl.spec.tsx +11 -10
- package/src/select/Select.spec.js +71 -71
- package/src/test-utils/index.js +1 -1
- package/src/test-utils/jest.setup.js +0 -2
- package/src/tooltip/Tooltip.spec.tsx +16 -15
- package/src/uploadInput/UploadInput.spec.tsx +10 -9
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +4 -4
- package/src/uploadInput/uploadItem/UploadItem.spec.tsx +4 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import React from 'react';
|
|
3
4
|
|
|
4
5
|
import Tooltip from '.';
|
|
5
6
|
|
|
@@ -25,7 +26,7 @@ describe('Tooltip Component', () => {
|
|
|
25
26
|
expect(tooltip).toHaveAttribute('aria-hidden', 'true');
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
it('should render the tooltip label when closed',
|
|
29
|
+
it('should render the tooltip label when closed', () => {
|
|
29
30
|
render(
|
|
30
31
|
<Tooltip label="Test Tooltip">
|
|
31
32
|
<span>Hover me</span>
|
|
@@ -35,11 +36,11 @@ describe('Tooltip Component', () => {
|
|
|
35
36
|
const tooltip = screen.getByRole('tooltip', { hidden: true });
|
|
36
37
|
expect(tooltip).toHaveAttribute('aria-hidden', 'true');
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
userEvent.hover(triggerElement);
|
|
39
40
|
expect(tooltip).toHaveAttribute('aria-hidden', 'false');
|
|
40
41
|
});
|
|
41
42
|
|
|
42
|
-
it('should display the tooltip on mouse hover',
|
|
43
|
+
it('should display the tooltip on mouse hover', () => {
|
|
43
44
|
render(
|
|
44
45
|
<Tooltip label="Test Tooltip">
|
|
45
46
|
<span>Hover over me!</span>
|
|
@@ -47,13 +48,13 @@ describe('Tooltip Component', () => {
|
|
|
47
48
|
);
|
|
48
49
|
const triggerElement = screen.getByText('Hover over me!');
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
userEvent.hover(triggerElement);
|
|
51
52
|
|
|
52
53
|
const tooltipElement = screen.queryByText('Test Tooltip');
|
|
53
54
|
expect(tooltipElement).toBeVisible();
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
it('should hide the tooltip on mouse out',
|
|
57
|
+
it('should hide the tooltip on mouse out', () => {
|
|
57
58
|
render(
|
|
58
59
|
<Tooltip label="Test Tooltip">
|
|
59
60
|
<span>Hover me</span>
|
|
@@ -61,16 +62,16 @@ describe('Tooltip Component', () => {
|
|
|
61
62
|
);
|
|
62
63
|
const triggerElement = screen.getByText('Hover me');
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
userEvent.hover(triggerElement);
|
|
65
66
|
let tooltipElement = screen.getByText('Test Tooltip');
|
|
66
67
|
expect(tooltipElement).toBeVisible();
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
userEvent.unhover(triggerElement);
|
|
69
70
|
tooltipElement = screen.getByRole('tooltip', { hidden: true });
|
|
70
71
|
expect(tooltipElement).toHaveAttribute('aria-hidden', 'true');
|
|
71
72
|
});
|
|
72
73
|
|
|
73
|
-
it('should display the tooltip on focus',
|
|
74
|
+
it('should display the tooltip on focus', () => {
|
|
74
75
|
render(
|
|
75
76
|
<Tooltip label="Test Tooltip">
|
|
76
77
|
<span>Focus me</span>
|
|
@@ -78,12 +79,12 @@ describe('Tooltip Component', () => {
|
|
|
78
79
|
);
|
|
79
80
|
const triggerElement = screen.getByText('Focus me');
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
userEvent.tab();
|
|
82
83
|
const tooltipElement = screen.getByText('Test Tooltip');
|
|
83
84
|
expect(tooltipElement).toBeVisible();
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
it('should hide the tooltip on blur',
|
|
87
|
+
it('should hide the tooltip on blur', () => {
|
|
87
88
|
render(
|
|
88
89
|
<Tooltip label="Test Tooltip">
|
|
89
90
|
<span>Focus me</span>
|
|
@@ -91,16 +92,16 @@ describe('Tooltip Component', () => {
|
|
|
91
92
|
);
|
|
92
93
|
const triggerElement = screen.getByText('Focus me');
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
userEvent.tab();
|
|
95
96
|
let tooltipElement = screen.getByRole('tooltip', { hidden: true });
|
|
96
97
|
expect(tooltipElement).toBeVisible();
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
userEvent.tab({ shift: true }); // Blur the element
|
|
99
100
|
tooltipElement = screen.getByRole('tooltip', { hidden: true });
|
|
100
101
|
expect(tooltipElement).toHaveAttribute('aria-hidden', 'true');
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
it('should display the tooltip when the "children" prop is a React element',
|
|
104
|
+
it('should display the tooltip when the "children" prop is a React element', () => {
|
|
104
105
|
render(
|
|
105
106
|
<Tooltip label="Test Tooltip">
|
|
106
107
|
<button type="button">Click me</button>
|
|
@@ -108,7 +109,7 @@ describe('Tooltip Component', () => {
|
|
|
108
109
|
);
|
|
109
110
|
const triggerElement = screen.getByText('Click me');
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
userEvent.hover(triggerElement);
|
|
112
113
|
const tooltipElement = screen.getByRole('tooltip', { hidden: true });
|
|
113
114
|
expect(tooltipElement).toBeVisible();
|
|
114
115
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { within } from '@testing-library/react';
|
|
2
|
-
import
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { Status } from '../common';
|
|
5
5
|
import { mockMatchMedia, render, screen, waitFor, waitForElementToBeRemoved } from '../test-utils';
|
|
@@ -9,8 +9,6 @@ import { TEST_IDS as UPLOAD_BUTTON_TEST_IDS } from './uploadButton/UploadButton'
|
|
|
9
9
|
import { TEST_IDS as UPLOAD_ITEM_TEST_IDS } from './uploadItem/UploadItem';
|
|
10
10
|
import { act } from 'react';
|
|
11
11
|
|
|
12
|
-
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTimeAsync });
|
|
13
|
-
|
|
14
12
|
mockMatchMedia();
|
|
15
13
|
|
|
16
14
|
describe('UploadInput', () => {
|
|
@@ -60,7 +58,10 @@ describe('UploadInput', () => {
|
|
|
60
58
|
renderComponent({ ...props, onFilesChange });
|
|
61
59
|
|
|
62
60
|
const input = screen.getByTestId(UPLOAD_BUTTON_TEST_IDS.uploadInput);
|
|
63
|
-
|
|
61
|
+
userEvent.upload(input, [pngFile, jpgFile]);
|
|
62
|
+
await act(async () => {
|
|
63
|
+
await jest.runOnlyPendingTimersAsync();
|
|
64
|
+
});
|
|
64
65
|
|
|
65
66
|
expect(props.onUploadFile).toHaveBeenCalledTimes(1);
|
|
66
67
|
expect(onFilesChange).toHaveBeenCalledTimes(2);
|
|
@@ -115,7 +116,7 @@ describe('UploadInput', () => {
|
|
|
115
116
|
expect(screen.getByTestId(UPLOAD_BUTTON_TEST_IDS.uploadInput)).toHaveAttribute('multiple');
|
|
116
117
|
|
|
117
118
|
const input = screen.getByTestId(UPLOAD_BUTTON_TEST_IDS.uploadInput);
|
|
118
|
-
|
|
119
|
+
userEvent.upload(input, [pngFile, jpgFile]);
|
|
119
120
|
|
|
120
121
|
await waitFor(() => {
|
|
121
122
|
expect(props.onUploadFile).toHaveBeenCalledTimes(2);
|
|
@@ -243,11 +244,11 @@ describe('UploadInput', () => {
|
|
|
243
244
|
});
|
|
244
245
|
|
|
245
246
|
const input = screen.getByTestId(UPLOAD_BUTTON_TEST_IDS.uploadInput);
|
|
246
|
-
|
|
247
|
+
userEvent.upload(input, [pngFile, jpgFile]);
|
|
247
248
|
|
|
248
249
|
const pngFile2 = new File(['foo2'], 'foo2.png', { type: 'image/png' });
|
|
249
250
|
const jpgFile2 = new File(['foo2'], 'foo2.jpg', { type: 'image/jpeg' });
|
|
250
|
-
|
|
251
|
+
userEvent.upload(input, [pngFile2, jpgFile2]);
|
|
251
252
|
|
|
252
253
|
await waitFor(() => {
|
|
253
254
|
expect(screen.getByText(maxFilesReachedMessage)).toBeInTheDocument();
|
|
@@ -273,7 +274,7 @@ describe('UploadInput', () => {
|
|
|
273
274
|
const input = screen.getByTestId(UPLOAD_BUTTON_TEST_IDS.uploadInput);
|
|
274
275
|
const pngFile2 = new File(['foo2'], 'foo2.png', { type: 'image/png' });
|
|
275
276
|
|
|
276
|
-
|
|
277
|
+
userEvent.upload(input, [pngFile, jpgFile, pngFile2]);
|
|
277
278
|
|
|
278
279
|
await waitFor(() => {
|
|
279
280
|
expect(screen.getByText(defaultMaxFilesReachedMessage)).toBeInTheDocument();
|
|
@@ -304,7 +305,7 @@ describe('UploadInput', () => {
|
|
|
304
305
|
const overSizedFile = new File([''], 'testFile.png', { type: 'image/png' });
|
|
305
306
|
Object.defineProperty(overSizedFile, 'size', { value: twoKbInBytes });
|
|
306
307
|
|
|
307
|
-
|
|
308
|
+
userEvent.upload(input, [overSizedFile]);
|
|
308
309
|
await waitFor(() => {
|
|
309
310
|
expect(screen.getByText(sizeLimitErrorMessage)).toBeInTheDocument();
|
|
310
311
|
});
|
|
@@ -35,9 +35,9 @@ describe('UploadButton', () => {
|
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it('trigger onChange callback with a FileList',
|
|
38
|
+
it('trigger onChange callback with a FileList', () => {
|
|
39
39
|
const input = screen.getByTestId(TEST_IDS.uploadInput);
|
|
40
|
-
|
|
40
|
+
userEvent.upload(input, [pngFile, jpgFile]);
|
|
41
41
|
|
|
42
42
|
expect(props.onChange).toHaveBeenCalledTimes(1);
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -55,9 +55,9 @@ describe('UploadButton', () => {
|
|
|
55
55
|
expect(screen.getByTestId(TEST_IDS.uploadInput)).toHaveAttribute('multiple');
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it('trigger onChange callback with a FileList',
|
|
58
|
+
it('trigger onChange callback with a FileList', () => {
|
|
59
59
|
const input = screen.getByTestId(TEST_IDS.uploadInput);
|
|
60
|
-
|
|
60
|
+
userEvent.upload(input, [pngFile, jpgFile]);
|
|
61
61
|
|
|
62
62
|
expect(props.onChange).toHaveBeenCalledTimes(1);
|
|
63
63
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import userEvent from '@testing-library/user-event';
|
|
2
2
|
|
|
3
3
|
import { Status } from '../../common';
|
|
4
4
|
import { render, screen } from '../../test-utils';
|
|
5
5
|
|
|
6
|
-
import UploadItem, { UploadItemProps } from './UploadItem';
|
|
6
|
+
import UploadItem, { UploadItemProps, TEST_IDS } from './UploadItem';
|
|
7
7
|
|
|
8
8
|
describe('UploadItem', () => {
|
|
9
9
|
const props: UploadItemProps = {
|
|
@@ -111,10 +111,10 @@ describe('UploadItem', () => {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
describe('manual file download handler', () => {
|
|
114
|
-
it('calls onDownload handler provided through props',
|
|
114
|
+
it('calls onDownload handler provided through props', () => {
|
|
115
115
|
const onDownload = jest.fn();
|
|
116
116
|
renderComponent({ ...props, onDownload });
|
|
117
|
-
|
|
117
|
+
userEvent.click(screen.getAllByRole('link')[0]);
|
|
118
118
|
expect(onDownload).toHaveBeenCalledTimes(1);
|
|
119
119
|
expect(onDownload).toHaveBeenCalledWith(props.file);
|
|
120
120
|
});
|