@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
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
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { action } from '@storybook/addon-actions';
|
|
2
|
-
import {
|
|
2
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
3
3
|
|
|
4
4
|
import { Status } from '../common';
|
|
5
5
|
|
|
@@ -14,6 +14,8 @@ const meta: Meta<typeof UploadInput> = {
|
|
|
14
14
|
|
|
15
15
|
export default meta;
|
|
16
16
|
|
|
17
|
+
type Story = StoryFn<UploadInputProps>;
|
|
18
|
+
|
|
17
19
|
const files = [
|
|
18
20
|
{
|
|
19
21
|
id: 1,
|
|
@@ -61,46 +63,46 @@ const createDelayedPromise = async ({
|
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
const props = {
|
|
64
|
-
onUploadFile: async (
|
|
66
|
+
onUploadFile: async () => {
|
|
65
67
|
return createDelayedPromise();
|
|
66
68
|
},
|
|
67
|
-
onDeleteFile: async (
|
|
69
|
+
onDeleteFile: async () => {
|
|
68
70
|
return createDelayedPromise();
|
|
69
71
|
},
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
const Template: Story
|
|
74
|
+
const Template: Story = (args: UploadInputProps) => <UploadInput {...args} />;
|
|
73
75
|
|
|
74
|
-
export const SingleFile: Story
|
|
76
|
+
export const SingleFile: Story = Template.bind({});
|
|
75
77
|
SingleFile.args = { ...props };
|
|
76
78
|
|
|
77
|
-
export const MultipleFiles: Story
|
|
79
|
+
export const MultipleFiles: Story = Template.bind({});
|
|
78
80
|
MultipleFiles.args = { ...props, multiple: true };
|
|
79
81
|
|
|
80
|
-
export const UploadInputWithDescriptionFromProps: Story
|
|
82
|
+
export const UploadInputWithDescriptionFromProps: Story = Template.bind({});
|
|
81
83
|
UploadInputWithDescriptionFromProps.args = {
|
|
82
84
|
...props,
|
|
83
85
|
multiple: true,
|
|
84
86
|
description: 'Custom file description from prop',
|
|
85
87
|
};
|
|
86
88
|
|
|
87
|
-
export const Disabled: Story
|
|
89
|
+
export const Disabled: Story = Template.bind({});
|
|
88
90
|
Disabled.args = { ...props, disabled: true };
|
|
89
91
|
|
|
90
|
-
export const WithAnyFileType: Story
|
|
92
|
+
export const WithAnyFileType: Story = Template.bind({});
|
|
91
93
|
WithAnyFileType.args = { ...props, fileTypes: '*' };
|
|
92
94
|
|
|
93
|
-
export const WithSingleFileType: Story
|
|
95
|
+
export const WithSingleFileType: Story = Template.bind({});
|
|
94
96
|
WithSingleFileType.args = { ...props, fileTypes: '.zip,application/zip' };
|
|
95
97
|
|
|
96
|
-
export const WithMultipleExistingFiles: Story
|
|
98
|
+
export const WithMultipleExistingFiles: Story = Template.bind({});
|
|
97
99
|
WithMultipleExistingFiles.args = {
|
|
98
100
|
...props,
|
|
99
101
|
files,
|
|
100
102
|
multiple: true,
|
|
101
103
|
};
|
|
102
104
|
|
|
103
|
-
export const WithFileErrors: Story
|
|
105
|
+
export const WithFileErrors: Story = Template.bind({});
|
|
104
106
|
WithFileErrors.args = {
|
|
105
107
|
...props,
|
|
106
108
|
files: [
|
|
@@ -143,7 +145,7 @@ WithFileErrors.args = {
|
|
|
143
145
|
multiple: true,
|
|
144
146
|
};
|
|
145
147
|
|
|
146
|
-
export const WithoutDelete: Story
|
|
148
|
+
export const WithoutDelete: Story = Template.bind({});
|
|
147
149
|
WithoutDelete.args = {
|
|
148
150
|
...props,
|
|
149
151
|
files,
|
|
@@ -151,7 +153,7 @@ WithoutDelete.args = {
|
|
|
151
153
|
multiple: true,
|
|
152
154
|
};
|
|
153
155
|
|
|
154
|
-
export const WithUploadFailed: Story
|
|
156
|
+
export const WithUploadFailed: Story = Template.bind({});
|
|
155
157
|
WithUploadFailed.args = {
|
|
156
158
|
...props,
|
|
157
159
|
files: files.slice(0),
|
|
@@ -159,7 +161,7 @@ WithUploadFailed.args = {
|
|
|
159
161
|
multiple: true,
|
|
160
162
|
};
|
|
161
163
|
|
|
162
|
-
export const WithDeleteFailed: Story
|
|
164
|
+
export const WithDeleteFailed: Story = Template.bind({});
|
|
163
165
|
WithDeleteFailed.args = {
|
|
164
166
|
...props,
|
|
165
167
|
files: files.slice(0),
|
|
@@ -167,7 +169,7 @@ WithDeleteFailed.args = {
|
|
|
167
169
|
multiple: true,
|
|
168
170
|
};
|
|
169
171
|
|
|
170
|
-
export const CustomConfirmMessage: Story
|
|
172
|
+
export const CustomConfirmMessage: Story = Template.bind({});
|
|
171
173
|
CustomConfirmMessage.args = {
|
|
172
174
|
...props,
|
|
173
175
|
files: files.slice(0),
|
|
@@ -182,21 +184,21 @@ CustomConfirmMessage.args = {
|
|
|
182
184
|
},
|
|
183
185
|
};
|
|
184
186
|
|
|
185
|
-
export const withManualDownloadHandler: Story
|
|
187
|
+
export const withManualDownloadHandler: Story = Template.bind({});
|
|
186
188
|
withManualDownloadHandler.args = {
|
|
187
189
|
...props,
|
|
188
190
|
files,
|
|
189
191
|
onDownload: action('Manual download handler'),
|
|
190
192
|
};
|
|
191
193
|
|
|
192
|
-
export const withFilesChangeHandler: Story
|
|
194
|
+
export const withFilesChangeHandler: Story = Template.bind({});
|
|
193
195
|
withFilesChangeHandler.args = {
|
|
194
196
|
...props,
|
|
195
197
|
files,
|
|
196
198
|
onFilesChange: action('Files change handler'),
|
|
197
199
|
};
|
|
198
200
|
|
|
199
|
-
export const withMaxFilesToUploadLimit: Story
|
|
201
|
+
export const withMaxFilesToUploadLimit: Story = Template.bind({});
|
|
200
202
|
withMaxFilesToUploadLimit.args = {
|
|
201
203
|
...props,
|
|
202
204
|
multiple: true,
|
|
@@ -204,14 +206,14 @@ withMaxFilesToUploadLimit.args = {
|
|
|
204
206
|
maxFilesErrorMessage: "Can't upload as maximum number of files allowed are already uploaded",
|
|
205
207
|
};
|
|
206
208
|
|
|
207
|
-
export const withFileSizeErrorMessage: Story
|
|
209
|
+
export const withFileSizeErrorMessage: Story = Template.bind({});
|
|
208
210
|
withFileSizeErrorMessage.args = {
|
|
209
211
|
...props,
|
|
210
212
|
sizeLimit: 1,
|
|
211
213
|
sizeLimitErrorMessage: 'The file is oversized',
|
|
212
214
|
};
|
|
213
215
|
|
|
214
|
-
export const withCustomUploadButtonTitle: Story
|
|
216
|
+
export const withCustomUploadButtonTitle: Story = Template.bind({});
|
|
215
217
|
withCustomUploadButtonTitle.args = {
|
|
216
218
|
...props,
|
|
217
219
|
uploadButtonTitle: 'Upload the VAT receipts for FY 2022-23',
|
|
@@ -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
|
});
|