@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.
Files changed (61) hide show
  1. package/build/index.js.map +1 -1
  2. package/build/index.mjs.map +1 -1
  3. package/build/types/info/Info.d.ts +2 -2
  4. package/build/types/info/Info.d.ts.map +1 -1
  5. package/build/types/info/index.d.ts +1 -1
  6. package/build/types/info/index.d.ts.map +1 -1
  7. package/package.json +25 -25
  8. package/src/accordion/Accordion.spec.js +5 -5
  9. package/src/accordion/AccordionItem/AccordionItem.spec.js +2 -2
  10. package/src/actionButton/ActionButton.spec.tsx +5 -4
  11. package/src/alert/Alert.spec.tsx +4 -4
  12. package/src/alert/Alert.story.tsx +6 -5
  13. package/src/button/Button.spec.js +5 -4
  14. package/src/card/Card.spec.tsx +4 -4
  15. package/src/carousel/Carousel.spec.tsx +17 -17
  16. package/src/checkbox/Checkbox.spec.tsx +2 -0
  17. package/src/checkboxButton/CheckboxButton.spec.tsx +2 -0
  18. package/src/checkboxOption/CheckboxOption.spec.tsx +2 -0
  19. package/src/chevron/Chevron.spec.tsx +1 -0
  20. package/src/chips/Chips.spec.tsx +1 -0
  21. package/src/chips/Chips.story.tsx +5 -3
  22. package/src/circularButton/CircularButton.spec.tsx +5 -4
  23. package/src/common/RadioButton/RadioButton.spec.tsx +2 -2
  24. package/src/common/card/Card.story.tsx +1 -0
  25. package/src/common/closeButton/CloseButton.spec.tsx +1 -0
  26. package/src/common/flowHeader/FlowHeader.spec.tsx +1 -0
  27. package/src/dateInput/DateInput.story.tsx +21 -16
  28. package/src/dateLookup/DateLookup.rtl.spec.tsx +16 -18
  29. package/src/dateLookup/DateLookup.testingLibrary.spec.js +44 -47
  30. package/src/dateLookup/DateLookup.tests.story.tsx +4 -2
  31. package/src/decision/Decision.spec.js +2 -0
  32. package/src/dimmer/Dimmer.rtl.spec.js +10 -10
  33. package/src/drawer/Drawer.rtl.spec.tsx +2 -2
  34. package/src/emphasis/Emphasis.spec.tsx +1 -0
  35. package/src/field/Field.spec.tsx +2 -2
  36. package/src/flowNavigation/FlowNavigation.spec.js +2 -0
  37. package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +1 -0
  38. package/src/header/Header.spec.tsx +6 -6
  39. package/src/image/Image.spec.tsx +1 -0
  40. package/src/info/Info.story.tsx +15 -9
  41. package/src/info/Info.tsx +2 -2
  42. package/src/info/index.ts +1 -1
  43. package/src/inlineAlert/InlineAlert.spec.tsx +1 -0
  44. package/src/inputs/SelectInput.spec.tsx +47 -26
  45. package/src/link/Link.spec.tsx +1 -0
  46. package/src/listItem/ListItem.spec.tsx +1 -0
  47. package/src/moneyInput/MoneyInput.rtl.spec.tsx +2 -2
  48. package/src/moneyInput/MoneyInput.story.tsx +1 -4
  49. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -0
  50. package/src/popover/Popover.spec.tsx +10 -10
  51. package/src/progress/Progress.spec.tsx +1 -0
  52. package/src/progressBar/ProgressBar.spec.tsx +1 -0
  53. package/src/segmentedControl/SegmentedControl.spec.tsx +11 -10
  54. package/src/select/Select.spec.js +71 -71
  55. package/src/test-utils/index.js +1 -1
  56. package/src/test-utils/jest.setup.js +0 -2
  57. package/src/tooltip/Tooltip.spec.tsx +16 -15
  58. package/src/uploadInput/UploadInput.spec.tsx +10 -9
  59. package/src/uploadInput/UploadInput.story.tsx +23 -21
  60. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +4 -4
  61. package/src/uploadInput/uploadItem/UploadItem.spec.tsx +4 -4
@@ -1,5 +1,5 @@
1
1
  import { within } from '@testing-library/react';
2
- import { userEvent } from '@testing-library/user-event';
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
- await user.upload(input, [pngFile, jpgFile]);
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
- await user.upload(input, [pngFile, jpgFile]);
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
- await user.upload(input, [pngFile, jpgFile]);
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
- await user.upload(input, [pngFile2, jpgFile2]);
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
- await user.upload(input, [pngFile, jpgFile, pngFile2]);
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
- await user.upload(input, overSizedFile);
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 { Story, Meta } from '@storybook/react';
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 (formData: FormData) => {
66
+ onUploadFile: async () => {
65
67
  return createDelayedPromise();
66
68
  },
67
- onDeleteFile: async (id: string | number) => {
69
+ onDeleteFile: async () => {
68
70
  return createDelayedPromise();
69
71
  },
70
72
  };
71
73
 
72
- const Template: Story<UploadInputProps> = (args: UploadInputProps) => <UploadInput {...args} />;
74
+ const Template: Story = (args: UploadInputProps) => <UploadInput {...args} />;
73
75
 
74
- export const SingleFile: Story<UploadInputProps> = Template.bind({});
76
+ export const SingleFile: Story = Template.bind({});
75
77
  SingleFile.args = { ...props };
76
78
 
77
- export const MultipleFiles: Story<UploadInputProps> = Template.bind({});
79
+ export const MultipleFiles: Story = Template.bind({});
78
80
  MultipleFiles.args = { ...props, multiple: true };
79
81
 
80
- export const UploadInputWithDescriptionFromProps: Story<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
89
+ export const Disabled: Story = Template.bind({});
88
90
  Disabled.args = { ...props, disabled: true };
89
91
 
90
- export const WithAnyFileType: Story<UploadInputProps> = Template.bind({});
92
+ export const WithAnyFileType: Story = Template.bind({});
91
93
  WithAnyFileType.args = { ...props, fileTypes: '*' };
92
94
 
93
- export const WithSingleFileType: Story<UploadInputProps> = Template.bind({});
95
+ export const WithSingleFileType: Story = Template.bind({});
94
96
  WithSingleFileType.args = { ...props, fileTypes: '.zip,application/zip' };
95
97
 
96
- export const WithMultipleExistingFiles: Story<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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<UploadInputProps> = Template.bind({});
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', async () => {
38
+ it('trigger onChange callback with a FileList', () => {
39
39
  const input = screen.getByTestId(TEST_IDS.uploadInput);
40
- await userEvent.upload(input, [pngFile, jpgFile]);
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', async () => {
58
+ it('trigger onChange callback with a FileList', () => {
59
59
  const input = screen.getByTestId(TEST_IDS.uploadInput);
60
- await userEvent.upload(input, [pngFile, jpgFile]);
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 { userEvent } from '@testing-library/user-event';
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', async () => {
114
+ it('calls onDownload handler provided through props', () => {
115
115
  const onDownload = jest.fn();
116
116
  renderComponent({ ...props, onDownload });
117
- await userEvent.click(screen.getAllByRole('link')[0]);
117
+ userEvent.click(screen.getAllByRole('link')[0]);
118
118
  expect(onDownload).toHaveBeenCalledTimes(1);
119
119
  expect(onDownload).toHaveBeenCalledWith(props.file);
120
120
  });