@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,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
import user from '@testing-library/user-event';
|
|
2
3
|
import { act } from 'react';
|
|
3
4
|
|
|
4
5
|
import { render, screen, mockMatchMedia } from '../test-utils';
|
|
@@ -54,103 +55,103 @@ describe('DateLookup (events)', () => {
|
|
|
54
55
|
|
|
55
56
|
it('switches to years', async () => {
|
|
56
57
|
const view = await setup();
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
openDateLookup(view);
|
|
59
|
+
clickDateButton(view);
|
|
59
60
|
|
|
60
61
|
expect(getActiveYearButton(view)).toHaveFocus();
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
closeDateLookup(view);
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
it('has aria-label for 20 years', async () => {
|
|
66
67
|
const view = await setup();
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
openDateLookup(view);
|
|
69
|
+
clickDateButton(view);
|
|
69
70
|
|
|
70
71
|
expect(getButtonByAriaLabel('next 20 years')).toBeInTheDocument();
|
|
71
72
|
expect(getButtonByAriaLabel('previous 20 years')).toBeInTheDocument();
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
closeDateLookup(view);
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
it('switches to months', async () => {
|
|
77
78
|
const view = await setup();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
openDateLookup(view);
|
|
80
|
+
clickDateButton(view);
|
|
81
|
+
user.click(getActiveYearButton(view));
|
|
81
82
|
|
|
82
83
|
expect(getActiveMonthButton(view)).toHaveFocus();
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
closeDateLookup(view);
|
|
85
86
|
});
|
|
86
87
|
|
|
87
88
|
it('has aria label for year', async () => {
|
|
88
89
|
const view = await setup();
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
openDateLookup(view);
|
|
91
|
+
clickDateButton(view);
|
|
92
|
+
user.click(getActiveYearButton(view));
|
|
92
93
|
|
|
93
94
|
expect(getButtonByAriaLabel('next year')).toBeInTheDocument();
|
|
94
95
|
expect(getButtonByAriaLabel('previous year')).toBeInTheDocument();
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
closeDateLookup(view);
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
it('switches to days', async () => {
|
|
100
101
|
const view = await setup();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
openDateLookup(view);
|
|
103
|
+
clickDateButton(view);
|
|
104
|
+
user.click(getActiveYearButton(view));
|
|
105
|
+
user.click(getActiveMonthButton(view));
|
|
105
106
|
|
|
106
107
|
expect(getActiveDayButton(view)).toHaveFocus();
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
closeDateLookup(view);
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
it('has aria label for month', async () => {
|
|
112
113
|
const view = await setup();
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
openDateLookup(view);
|
|
115
|
+
clickDateButton(view);
|
|
116
|
+
user.click(getActiveYearButton(view));
|
|
117
|
+
user.click(getActiveMonthButton(view));
|
|
117
118
|
|
|
118
119
|
expect(getButtonByAriaLabel('next month')).toBeInTheDocument();
|
|
119
120
|
expect(getButtonByAriaLabel('previous month')).toBeInTheDocument();
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
closeDateLookup(view);
|
|
122
123
|
});
|
|
123
124
|
|
|
124
125
|
it('updates selected date and closes', async () => {
|
|
125
126
|
const view = await setup();
|
|
126
|
-
|
|
127
|
+
openDateLookup(view);
|
|
127
128
|
const d = new Date(2018, 11, 28);
|
|
128
129
|
const newDay = screen.getByText(d.getDate().toString());
|
|
129
|
-
|
|
130
|
+
user.click(newDay);
|
|
130
131
|
|
|
131
132
|
expect(handleChange).toHaveBeenCalledWith(d);
|
|
132
133
|
expect(getOpenButton(view)).toHaveFocus();
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
closeDateLookup(view);
|
|
135
136
|
});
|
|
136
137
|
|
|
137
138
|
it('has aria label on selected date', async () => {
|
|
138
139
|
const view = await setup();
|
|
139
|
-
|
|
140
|
+
openDateLookup(view);
|
|
140
141
|
const d = new Date(2018, 11, 28);
|
|
141
142
|
const newDay = screen.getByText(d.getDate().toString());
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
user.click(newDay);
|
|
144
|
+
openDateLookup(view);
|
|
144
145
|
expect(screen.getByRole('button', { name: /selected day/i })).toBeInTheDocument();
|
|
145
146
|
|
|
146
|
-
|
|
147
|
+
closeDateLookup(view);
|
|
147
148
|
});
|
|
148
149
|
|
|
149
150
|
it('supports custom `aria-labelledby` attribute', async () => {
|
|
150
151
|
const view = await setup();
|
|
151
152
|
expect(screen.getByLabelText('Prioritized label')).toHaveClass('input-group');
|
|
152
153
|
|
|
153
|
-
|
|
154
|
+
closeDateLookup(view);
|
|
154
155
|
});
|
|
155
156
|
});
|
|
156
157
|
|
|
@@ -182,33 +183,29 @@ describe('DateLookup (events)', () => {
|
|
|
182
183
|
|
|
183
184
|
it('when user clicks on clear the focus returns to btn', async () => {
|
|
184
185
|
const view = await setup();
|
|
185
|
-
|
|
186
|
+
clickClearButton(view);
|
|
186
187
|
expect(getOpenButton(view)).toHaveFocus();
|
|
187
188
|
});
|
|
188
189
|
|
|
189
190
|
it('onChange gets called with null when reset button is clicked', async () => {
|
|
190
191
|
const view = await setup();
|
|
191
|
-
|
|
192
|
+
clickClearButton(view);
|
|
192
193
|
expect(props.onChange).toHaveBeenCalledWith(null);
|
|
193
194
|
});
|
|
194
195
|
});
|
|
195
196
|
|
|
196
|
-
const openDateLookup =
|
|
197
|
-
|
|
198
|
-
) => userEvent.click(getOpenButton(view));
|
|
197
|
+
const openDateLookup = (/** @type {import('@testing-library/react').RenderResult} */ view) =>
|
|
198
|
+
user.click(getOpenButton(view));
|
|
199
199
|
|
|
200
|
-
const clickDateButton =
|
|
201
|
-
|
|
202
|
-
) => userEvent.click(getDateButton(view));
|
|
200
|
+
const clickDateButton = (/** @type {import('@testing-library/react').RenderResult} */ view) =>
|
|
201
|
+
user.click(getDateButton(view));
|
|
203
202
|
|
|
204
203
|
// Close dateLookup and removes events attached to documents.
|
|
205
|
-
const closeDateLookup =
|
|
206
|
-
|
|
207
|
-
) => userEvent.click(view.container);
|
|
204
|
+
const closeDateLookup = (/** @type {import('@testing-library/react').RenderResult} */ view) =>
|
|
205
|
+
user.click(view.container);
|
|
208
206
|
|
|
209
|
-
const clickClearButton =
|
|
210
|
-
|
|
211
|
-
) => userEvent.click(getClearButton(view));
|
|
207
|
+
const clickClearButton = (/** @type {import('@testing-library/react').RenderResult} */ view) =>
|
|
208
|
+
user.click(getClearButton(view));
|
|
212
209
|
|
|
213
210
|
const getActiveYearButton = (
|
|
214
211
|
/** @type {import('@testing-library/react').RenderResult} */ view,
|
|
@@ -25,42 +25,42 @@ describe('Dimmer', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
describe('closing behaviour', () => {
|
|
28
|
-
it('calls onClose if the dimmer is clicked',
|
|
28
|
+
it('calls onClose if the dimmer is clicked', () => {
|
|
29
29
|
const onClose = jest.fn();
|
|
30
30
|
render(<Dimmer {...props} onClose={onClose} />);
|
|
31
|
-
|
|
31
|
+
userEvent.click(screen.getByRole('presentation'));
|
|
32
32
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it('does not call onClose if the dimmer content is clicked',
|
|
35
|
+
it('does not call onClose if the dimmer content is clicked', () => {
|
|
36
36
|
const onClose = jest.fn();
|
|
37
37
|
render(
|
|
38
38
|
<Dimmer {...props} onClose={onClose}>
|
|
39
39
|
<Button onClick={() => {}}>McClicky</Button>
|
|
40
40
|
</Dimmer>,
|
|
41
41
|
);
|
|
42
|
-
|
|
42
|
+
userEvent.click(screen.getByRole('button'));
|
|
43
43
|
expect(onClose).toHaveBeenCalledTimes(0);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
it('does not call onClose when clicked if disableClickToClose is true',
|
|
46
|
+
it('does not call onClose when clicked if disableClickToClose is true', () => {
|
|
47
47
|
const onClose = jest.fn();
|
|
48
48
|
render(<Dimmer {...props} disableClickToClose onClose={onClose} />);
|
|
49
|
-
|
|
49
|
+
userEvent.click(screen.getByRole('presentation'));
|
|
50
50
|
expect(onClose).toHaveBeenCalledTimes(0);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
it('calls onClose if the escape key is pressed',
|
|
53
|
+
it('calls onClose if the escape key is pressed', () => {
|
|
54
54
|
const onClose = jest.fn();
|
|
55
55
|
render(<Dimmer {...props} onClose={onClose} />);
|
|
56
|
-
|
|
56
|
+
userEvent.keyboard('{esc}');
|
|
57
57
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it('does not call onClose if the escape key is pressed when disableClickToClose is true',
|
|
60
|
+
it('does not call onClose if the escape key is pressed when disableClickToClose is true', () => {
|
|
61
61
|
const onClose = jest.fn();
|
|
62
62
|
render(<Dimmer {...props} disableClickToClose onClose={onClose} />);
|
|
63
|
-
|
|
63
|
+
userEvent.keyboard('{esc}');
|
|
64
64
|
expect(onClose).toHaveBeenCalledTimes(1);
|
|
65
65
|
});
|
|
66
66
|
});
|
|
@@ -48,10 +48,10 @@ describe('Drawer', () => {
|
|
|
48
48
|
expect(container).toMatchSnapshot();
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
it('calls onClose when user clicks close button',
|
|
51
|
+
it('calls onClose when user clicks close button', () => {
|
|
52
52
|
render(<Drawer {...props}>content</Drawer>);
|
|
53
53
|
expect(props.onClose).not.toHaveBeenCalled();
|
|
54
|
-
|
|
54
|
+
userEvent.click(getCloseButton());
|
|
55
55
|
expect(props.onClose).toHaveBeenCalledTimes(1);
|
|
56
56
|
});
|
|
57
57
|
|
package/src/field/Field.spec.tsx
CHANGED
|
@@ -73,7 +73,7 @@ describe('Field', () => {
|
|
|
73
73
|
button.addEventListener('click', handleClick);
|
|
74
74
|
|
|
75
75
|
const label = screen.getByText('Phone number');
|
|
76
|
-
|
|
76
|
+
userEvent.click(label);
|
|
77
77
|
|
|
78
78
|
expect(handleClick).not.toHaveBeenCalled();
|
|
79
79
|
});
|
|
@@ -90,6 +90,6 @@ describe('Field', () => {
|
|
|
90
90
|
expect(screen.getByRole('textbox')).not.toHaveAttribute('id');
|
|
91
91
|
|
|
92
92
|
const label = screen.getByText('Phone number');
|
|
93
|
-
|
|
93
|
+
userEvent.click(label);
|
|
94
94
|
});
|
|
95
95
|
});
|
|
@@ -9,7 +9,7 @@ describe('Header', () => {
|
|
|
9
9
|
expect(screen.getByText('Header title')).toBeInTheDocument();
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
it('can trigger header action',
|
|
12
|
+
it('can trigger header action', () => {
|
|
13
13
|
const onHeaderActionClick = jest.fn();
|
|
14
14
|
|
|
15
15
|
render(
|
|
@@ -22,12 +22,12 @@ describe('Header', () => {
|
|
|
22
22
|
/>,
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
userEvent.click(screen.getByRole('button', { name: 'Click me!' }));
|
|
26
26
|
|
|
27
27
|
expect(onHeaderActionClick).toHaveBeenCalledTimes(1);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it('can set aria-label property for header action',
|
|
30
|
+
it('can set aria-label property for header action', () => {
|
|
31
31
|
const onHeaderActionClick = jest.fn();
|
|
32
32
|
|
|
33
33
|
render(
|
|
@@ -41,7 +41,7 @@ describe('Header', () => {
|
|
|
41
41
|
/>,
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
userEvent.click(screen.getByRole('button', { name: 'Magic' }));
|
|
45
45
|
|
|
46
46
|
expect(onHeaderActionClick).toHaveBeenCalledTimes(1);
|
|
47
47
|
});
|
|
@@ -75,7 +75,7 @@ describe('Header', () => {
|
|
|
75
75
|
expect(screen.getByRole('heading', { name: 'Header title', level: 3 })).toBeInTheDocument();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
it('runs onClick if specified even when it got href prop',
|
|
78
|
+
it('runs onClick if specified even when it got href prop', () => {
|
|
79
79
|
const callback = jest.fn();
|
|
80
80
|
render(
|
|
81
81
|
<Header
|
|
@@ -88,7 +88,7 @@ describe('Header', () => {
|
|
|
88
88
|
const button = screen.getByRole('link', { name: 'Click me' });
|
|
89
89
|
expect(button).toBeInTheDocument();
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
userEvent.click(button);
|
|
92
92
|
|
|
93
93
|
expect(callback).toHaveBeenCalledTimes(1);
|
|
94
94
|
});
|
package/src/image/Image.spec.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { screen, waitFor, within } from '@testing-library/react';
|
|
2
|
-
import
|
|
1
|
+
import { act, screen, waitFor, within } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { render, mockMatchMedia, mockResizeObserver } from '../test-utils';
|
|
5
5
|
|
|
@@ -42,22 +42,25 @@ describe('SelectInput', () => {
|
|
|
42
42
|
/>,
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
await
|
|
46
|
-
await
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
46
|
+
await act(async () => {
|
|
47
|
+
userEvent.tab();
|
|
48
|
+
userEvent.keyboard(' ');
|
|
49
|
+
});
|
|
47
50
|
|
|
48
51
|
const footer = screen.getByText('All items shown');
|
|
49
52
|
expect(footer).toBeInTheDocument();
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
userEvent.keyboard('u');
|
|
52
55
|
expect(footer).toHaveTextContent(/‘u’$/);
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
userEvent.keyboard('r');
|
|
55
58
|
expect(footer).toHaveTextContent(/‘ur’$/);
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
userEvent.keyboard('x');
|
|
58
61
|
expect(footer).toHaveTextContent(/‘urx’$/);
|
|
59
62
|
|
|
60
|
-
|
|
63
|
+
userEvent.keyboard('{Backspace}');
|
|
61
64
|
expect(footer).toHaveTextContent(/‘ur’$/);
|
|
62
65
|
});
|
|
63
66
|
|
|
@@ -77,13 +80,16 @@ describe('SelectInput', () => {
|
|
|
77
80
|
expect(screen.queryByText('EUR')).not.toBeInTheDocument();
|
|
78
81
|
|
|
79
82
|
const trigger = screen.getAllByRole('button')[0];
|
|
80
|
-
await
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
84
|
+
await act(async () => {
|
|
85
|
+
userEvent.click(trigger);
|
|
86
|
+
});
|
|
81
87
|
|
|
82
88
|
expect(handleClose).not.toHaveBeenCalled();
|
|
83
89
|
|
|
84
90
|
const listbox = screen.getByRole('listbox');
|
|
85
91
|
const option = within(listbox).getByRole('option', { name: 'EUR' });
|
|
86
|
-
|
|
92
|
+
userEvent.click(option);
|
|
87
93
|
|
|
88
94
|
expect(handleClose).toHaveBeenCalledTimes(1);
|
|
89
95
|
expect(trigger).toHaveTextContent('EUR');
|
|
@@ -111,28 +117,34 @@ describe('SelectInput', () => {
|
|
|
111
117
|
);
|
|
112
118
|
|
|
113
119
|
const trigger = screen.getAllByRole('button')[0];
|
|
114
|
-
await
|
|
115
|
-
await
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
121
|
+
await act(async () => {
|
|
122
|
+
userEvent.tab();
|
|
123
|
+
userEvent.keyboard(' ');
|
|
124
|
+
});
|
|
116
125
|
|
|
117
126
|
expect(handleClose).not.toHaveBeenCalled();
|
|
118
127
|
|
|
119
128
|
const listbox = screen.getByRole('listbox');
|
|
120
129
|
expect(within(listbox).getAllByRole('option')).toHaveLength(3);
|
|
121
130
|
|
|
122
|
-
|
|
131
|
+
userEvent.keyboard('u');
|
|
123
132
|
expect(within(listbox).getAllByRole('option')).toHaveLength(2);
|
|
124
133
|
|
|
125
|
-
|
|
134
|
+
userEvent.keyboard('r');
|
|
126
135
|
expect(within(listbox).getByRole('option')).toBeInTheDocument();
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
userEvent.keyboard('x');
|
|
129
138
|
expect(within(listbox).queryByRole('option')).not.toBeInTheDocument();
|
|
130
139
|
|
|
131
|
-
|
|
140
|
+
userEvent.keyboard('{Backspace}');
|
|
132
141
|
expect(within(listbox).getByRole('option')).toBeInTheDocument();
|
|
133
142
|
|
|
134
143
|
const option = within(listbox).getAllByRole('option')[0];
|
|
135
|
-
await
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
145
|
+
await act(async () => {
|
|
146
|
+
userEvent.click(option);
|
|
147
|
+
});
|
|
136
148
|
|
|
137
149
|
expect(handleClose).toHaveBeenCalledTimes(1);
|
|
138
150
|
expect(trigger).toHaveTextContent('EUR');
|
|
@@ -153,18 +165,21 @@ describe('SelectInput', () => {
|
|
|
153
165
|
);
|
|
154
166
|
|
|
155
167
|
const trigger = screen.getAllByRole('button')[0];
|
|
156
|
-
await
|
|
157
|
-
await
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
169
|
+
await act(async () => {
|
|
170
|
+
userEvent.tab();
|
|
171
|
+
userEvent.keyboard(' ');
|
|
172
|
+
});
|
|
158
173
|
|
|
159
174
|
expect(handleFilterChange).not.toHaveBeenCalled();
|
|
160
175
|
|
|
161
|
-
|
|
176
|
+
userEvent.keyboard(' x');
|
|
162
177
|
expect(handleFilterChange).toHaveBeenLastCalledWith({
|
|
163
178
|
query: ' x',
|
|
164
179
|
queryNormalized: 'x',
|
|
165
180
|
});
|
|
166
181
|
|
|
167
|
-
|
|
182
|
+
userEvent.keyboard('{Escape}');
|
|
168
183
|
await waitFor(() => {
|
|
169
184
|
expect(handleFilterChange).toHaveBeenLastCalledWith({
|
|
170
185
|
query: '',
|
|
@@ -172,7 +187,10 @@ describe('SelectInput', () => {
|
|
|
172
187
|
});
|
|
173
188
|
});
|
|
174
189
|
|
|
175
|
-
await
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
191
|
+
await act(async () => {
|
|
192
|
+
userEvent.click(trigger);
|
|
193
|
+
});
|
|
176
194
|
|
|
177
195
|
const listbox = screen.getByRole('listbox');
|
|
178
196
|
expect(within(listbox).getAllByRole('option')).toHaveLength(2);
|
|
@@ -190,13 +208,16 @@ describe('SelectInput', () => {
|
|
|
190
208
|
);
|
|
191
209
|
|
|
192
210
|
const trigger = screen.getAllByRole('button')[0];
|
|
193
|
-
await
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
212
|
+
await act(async () => {
|
|
213
|
+
userEvent.click(trigger);
|
|
214
|
+
});
|
|
194
215
|
|
|
195
216
|
const listbox = screen.getByRole('listbox');
|
|
196
217
|
const options = within(listbox).getAllByRole('option');
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
218
|
+
options.forEach((option) => {
|
|
219
|
+
userEvent.click(option);
|
|
220
|
+
});
|
|
200
221
|
|
|
201
222
|
expect(trigger).toHaveTextContent('USD, EUR');
|
|
202
223
|
});
|
package/src/link/Link.spec.tsx
CHANGED
|
@@ -62,11 +62,11 @@ describe('MoneyInput', () => {
|
|
|
62
62
|
['1±!@#$^*,_+?><2', '1,2'],
|
|
63
63
|
['12,3', '12,3'],
|
|
64
64
|
['12.3', '12.3'],
|
|
65
|
-
])("ignores the letters when typed '%s' and shows '%s'",
|
|
65
|
+
])("ignores the letters when typed '%s' and shows '%s'", (testValue, expectedValue) => {
|
|
66
66
|
render(<MoneyInput {...props} amount={null} />);
|
|
67
67
|
|
|
68
68
|
const input = screen.getByRole('textbox');
|
|
69
|
-
|
|
69
|
+
userEvent.type(input, testValue);
|
|
70
70
|
expect(input).toHaveValue(expectedValue);
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -29,7 +29,7 @@ describe('Popover', () => {
|
|
|
29
29
|
</Popover>,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
userEvent.click(screen.getByText('Open'));
|
|
33
33
|
|
|
34
34
|
await waitForPanel();
|
|
35
35
|
expect(getPanel()).toMatchSnapshot();
|
|
@@ -42,7 +42,7 @@ describe('Popover', () => {
|
|
|
42
42
|
</Popover>,
|
|
43
43
|
));
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
userEvent.click(screen.getByText('Open'));
|
|
46
46
|
await waitForPanel();
|
|
47
47
|
|
|
48
48
|
expect(getTitle()).toBeInTheDocument();
|
|
@@ -53,7 +53,7 @@ describe('Popover', () => {
|
|
|
53
53
|
</Popover>,
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
userEvent.click(screen.getByText('Open'));
|
|
57
57
|
|
|
58
58
|
expect(getTitle()).not.toBeInTheDocument();
|
|
59
59
|
});
|
|
@@ -67,7 +67,7 @@ describe('Popover', () => {
|
|
|
67
67
|
|
|
68
68
|
expect(getPanel()).not.toBeInTheDocument();
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
userEvent.click(screen.getByText('Open'));
|
|
71
71
|
await waitForPanel();
|
|
72
72
|
|
|
73
73
|
expect(getPanel()).toBeInTheDocument();
|
|
@@ -79,19 +79,19 @@ describe('Popover', () => {
|
|
|
79
79
|
global.innerWidth = Breakpoint.SMALL - 1;
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
it('renders when is open',
|
|
82
|
+
it('renders when is open', () => {
|
|
83
83
|
({ container } = render(
|
|
84
84
|
<Popover {...props}>
|
|
85
85
|
<button type="button">Open</button>
|
|
86
86
|
</Popover>,
|
|
87
87
|
));
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
userEvent.click(screen.getByText('Open'));
|
|
90
90
|
|
|
91
91
|
expect(container).toMatchSnapshot();
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
it('renders BottomSheet onClick',
|
|
94
|
+
it('renders BottomSheet onClick', () => {
|
|
95
95
|
render(
|
|
96
96
|
<Popover {...props}>
|
|
97
97
|
<button type="button">Open</button>
|
|
@@ -100,7 +100,7 @@ describe('Popover', () => {
|
|
|
100
100
|
|
|
101
101
|
expect(getBottomSheet()).not.toBeInTheDocument();
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
userEvent.click(screen.getByText('Open'));
|
|
104
104
|
|
|
105
105
|
expect(getBottomSheet()).toBeInTheDocument();
|
|
106
106
|
});
|
|
@@ -115,11 +115,11 @@ describe('Popover', () => {
|
|
|
115
115
|
);
|
|
116
116
|
|
|
117
117
|
expect(handleOnClose).not.toHaveBeenCalled();
|
|
118
|
-
|
|
118
|
+
userEvent.click(screen.getByText('Open'));
|
|
119
119
|
await waitForPanel();
|
|
120
120
|
const dimmer = getDimmer();
|
|
121
121
|
if (dimmer != null) {
|
|
122
|
-
|
|
122
|
+
userEvent.click(dimmer);
|
|
123
123
|
}
|
|
124
124
|
expect(handleOnClose).toHaveBeenCalledTimes(1);
|
|
125
125
|
});
|