@transferwise/components 0.0.0-experimental-40b5678 → 0.0.0-experimental-ef26b66
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/build/index.js.map +1 -1
- package/build/index.mjs.map +1 -1
- package/build/types/info/Info.d.ts +2 -2
- package/build/types/info/Info.d.ts.map +1 -1
- package/build/types/info/index.d.ts +1 -1
- package/build/types/info/index.d.ts.map +1 -1
- package/package.json +25 -25
- 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/alert/Alert.story.tsx +6 -5
- 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/chips/Chips.story.tsx +5 -3
- package/src/circularButton/CircularButton.spec.tsx +5 -4
- package/src/common/RadioButton/RadioButton.spec.tsx +2 -2
- package/src/common/card/Card.story.tsx +1 -0
- package/src/common/closeButton/CloseButton.spec.tsx +1 -0
- package/src/common/flowHeader/FlowHeader.spec.tsx +1 -0
- package/src/dateInput/DateInput.story.tsx +21 -16
- package/src/dateLookup/DateLookup.rtl.spec.tsx +16 -18
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +44 -47
- package/src/dateLookup/DateLookup.tests.story.tsx +4 -2
- 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/info/Info.story.tsx +15 -9
- package/src/info/Info.tsx +2 -2
- package/src/info/index.ts +1 -1
- 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/moneyInput/MoneyInput.story.tsx +1 -4
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -0
- 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/UploadInput.story.tsx +23 -21
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +4 -4
- package/src/uploadInput/uploadItem/UploadItem.spec.tsx +4 -4
|
@@ -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
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { FORCE_RE_RENDER } from '@storybook/core-events';
|
|
2
|
-
import { addons, useGlobals } from '@storybook/manager-api';
|
|
3
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
4
2
|
import { expect, within, userEvent } from '@storybook/test';
|
|
5
3
|
import { Lock } from '@transferwise/icons';
|
|
6
|
-
import
|
|
4
|
+
import { useState } from 'react';
|
|
7
5
|
|
|
8
6
|
import MoneyInput, { CurrencyOptionItem } from '.';
|
|
9
7
|
import Provider from '../provider/Provider';
|
|
@@ -107,7 +105,6 @@ export const SingleCurrency: Story = {
|
|
|
107
105
|
args: {
|
|
108
106
|
currencies: [],
|
|
109
107
|
selectedCurrency: exampleCurrency.eur,
|
|
110
|
-
onCurrencyChange: undefined,
|
|
111
108
|
},
|
|
112
109
|
};
|
|
113
110
|
|
|
@@ -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
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
|
|
3
4
|
import { render, screen, userEvent, waitFor } from '../test-utils';
|
|
@@ -59,30 +60,30 @@ describe('SegmentedControl', () => {
|
|
|
59
60
|
expect(accountingTab).toHaveAttribute('aria-selected', 'true');
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
it('lets the user pick through the segments when it is set to input',
|
|
63
|
+
it('lets the user pick through the segments when it is set to input', () => {
|
|
63
64
|
renderSegmentedControl();
|
|
64
65
|
|
|
65
66
|
const payroll = screen.getByRole('radio', { name: 'Payroll' });
|
|
66
|
-
|
|
67
|
+
userEvent.click(payroll);
|
|
67
68
|
|
|
68
69
|
expect(onChange).toHaveBeenCalledWith('payroll');
|
|
69
70
|
|
|
70
71
|
const reporting = screen.getByRole('radio', { name: 'Reporting' });
|
|
71
|
-
|
|
72
|
+
userEvent.click(reporting);
|
|
72
73
|
|
|
73
74
|
expect(onChange).toHaveBeenCalledWith('reporting');
|
|
74
75
|
});
|
|
75
76
|
|
|
76
|
-
it('lets the user pick through the segments when it is set to view',
|
|
77
|
+
it('lets the user pick through the segments when it is set to view', () => {
|
|
77
78
|
renderSegmentedControl({ mode: 'view', segments: defaultSegmentsWithControls });
|
|
78
79
|
|
|
79
80
|
const payroll = screen.getByRole('tab', { name: 'Payroll' });
|
|
80
|
-
|
|
81
|
+
userEvent.click(payroll);
|
|
81
82
|
|
|
82
83
|
expect(onChange).toHaveBeenCalledWith('payroll');
|
|
83
84
|
|
|
84
85
|
const reporting = screen.getByRole('tab', { name: 'Reporting' });
|
|
85
|
-
|
|
86
|
+
userEvent.click(reporting);
|
|
86
87
|
|
|
87
88
|
expect(onChange).toHaveBeenCalledWith('reporting');
|
|
88
89
|
});
|
|
@@ -133,11 +134,11 @@ describe('SegmentedControl', () => {
|
|
|
133
134
|
});
|
|
134
135
|
});
|
|
135
136
|
|
|
136
|
-
it('updates the selected segment when the selectedValue prop changes',
|
|
137
|
+
it('updates the selected segment when the selectedValue prop changes', () => {
|
|
137
138
|
const { rerender } = render(<SegmentedControl {...defaultProps} />);
|
|
138
139
|
|
|
139
140
|
const payroll = screen.getByRole('radio', { name: 'Payroll' });
|
|
140
|
-
|
|
141
|
+
userEvent.click(payroll);
|
|
141
142
|
|
|
142
143
|
expect(onChange).toHaveBeenCalledWith('payroll');
|
|
143
144
|
|
|
@@ -147,7 +148,7 @@ describe('SegmentedControl', () => {
|
|
|
147
148
|
expect(reporting).toBeChecked();
|
|
148
149
|
});
|
|
149
150
|
|
|
150
|
-
it('updates the options when the segments prop changes',
|
|
151
|
+
it('updates the options when the segments prop changes', () => {
|
|
151
152
|
const { rerender } = render(<SegmentedControl {...defaultProps} />);
|
|
152
153
|
|
|
153
154
|
const newSegments = [
|
|
@@ -166,7 +167,7 @@ describe('SegmentedControl', () => {
|
|
|
166
167
|
rerender(<SegmentedControl {...defaultProps} segments={newSegments} />);
|
|
167
168
|
|
|
168
169
|
const anotherOne = screen.getByRole('radio', { name: 'Another One' });
|
|
169
|
-
|
|
170
|
+
userEvent.click(anotherOne);
|
|
170
171
|
|
|
171
172
|
expect(onChange).toHaveBeenCalledWith('anotherOne');
|
|
172
173
|
});
|