@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
|
@@ -4,8 +4,6 @@ import DateLookup, { DateLookupProps } from './DateLookup';
|
|
|
4
4
|
|
|
5
5
|
import { act } from 'react';
|
|
6
6
|
|
|
7
|
-
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTimeAsync });
|
|
8
|
-
|
|
9
7
|
mockMatchMedia();
|
|
10
8
|
mockResizeObserver();
|
|
11
9
|
|
|
@@ -38,12 +36,12 @@ describe('DateLookup', () => {
|
|
|
38
36
|
async (text) => {
|
|
39
37
|
render(<DateLookup value={initialValue} onChange={() => {}} />);
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
userEvent.tab();
|
|
40
|
+
userEvent.keyboard(text);
|
|
43
41
|
|
|
44
42
|
expect(screen.getByRole('button', { name: /next/iu })).toBeInTheDocument();
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
userEvent.keyboard('{Escape}');
|
|
47
45
|
await act(async () => {
|
|
48
46
|
await jest.runOnlyPendingTimersAsync();
|
|
49
47
|
});
|
|
@@ -55,7 +53,7 @@ describe('DateLookup', () => {
|
|
|
55
53
|
const setupAndOpenWithMouse = async (props: Partial<DateLookupProps> = {}) => {
|
|
56
54
|
const view = render(<DateLookup value={initialValue} onChange={() => {}} {...props} />);
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
userEvent.click(screen.getByRole('button'));
|
|
59
57
|
await act(async () => {
|
|
60
58
|
await jest.runOnlyPendingTimersAsync();
|
|
61
59
|
});
|
|
@@ -70,7 +68,7 @@ describe('DateLookup', () => {
|
|
|
70
68
|
|
|
71
69
|
const dimmerElement = screen.getByRole('dialog').parentElement?.parentElement;
|
|
72
70
|
if (dimmerElement != null) {
|
|
73
|
-
|
|
71
|
+
userEvent.click(dimmerElement);
|
|
74
72
|
}
|
|
75
73
|
await act(async () => {
|
|
76
74
|
await jest.runOnlyPendingTimersAsync();
|
|
@@ -91,13 +89,13 @@ describe('DateLookup', () => {
|
|
|
91
89
|
|
|
92
90
|
expect(handleChange).not.toHaveBeenCalled();
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
userEvent.keyboard(text);
|
|
95
93
|
|
|
96
94
|
const value = new Date(initialValue);
|
|
97
95
|
value.setDate(initialValue.getDate() + step);
|
|
98
96
|
expect(handleChange).toHaveBeenCalledWith(value);
|
|
99
97
|
|
|
100
|
-
|
|
98
|
+
userEvent.keyboard('{Escape}');
|
|
101
99
|
await act(async () => {
|
|
102
100
|
await jest.runOnlyPendingTimersAsync();
|
|
103
101
|
});
|
|
@@ -116,20 +114,20 @@ describe('DateLookup', () => {
|
|
|
116
114
|
const handleChange = jest.fn();
|
|
117
115
|
await setupAndOpenWithMouse({ onChange: handleChange });
|
|
118
116
|
|
|
119
|
-
|
|
117
|
+
userEvent.click(screen.getByRole('button', { name: /year view/iu }));
|
|
120
118
|
await act(async () => {
|
|
121
119
|
await jest.runOnlyPendingTimersAsync();
|
|
122
120
|
});
|
|
123
121
|
|
|
124
122
|
expect(handleChange).not.toHaveBeenCalled();
|
|
125
123
|
|
|
126
|
-
|
|
124
|
+
userEvent.keyboard(text);
|
|
127
125
|
|
|
128
126
|
const value = new Date(initialValue);
|
|
129
127
|
value.setFullYear(initialValue.getFullYear() + step);
|
|
130
128
|
expect(handleChange).toHaveBeenCalledWith(value);
|
|
131
129
|
|
|
132
|
-
|
|
130
|
+
userEvent.keyboard('{Escape}');
|
|
133
131
|
await act(async () => {
|
|
134
132
|
await jest.runOnlyPendingTimersAsync();
|
|
135
133
|
});
|
|
@@ -148,24 +146,24 @@ describe('DateLookup', () => {
|
|
|
148
146
|
const handleChange = jest.fn();
|
|
149
147
|
await setupAndOpenWithMouse({ onChange: handleChange });
|
|
150
148
|
|
|
151
|
-
|
|
149
|
+
userEvent.click(screen.getByRole('button', { name: /year view/iu }));
|
|
152
150
|
await act(async () => {
|
|
153
151
|
await jest.runOnlyPendingTimersAsync();
|
|
154
152
|
});
|
|
155
|
-
|
|
153
|
+
userEvent.keyboard(' ');
|
|
156
154
|
await act(async () => {
|
|
157
155
|
await jest.runOnlyPendingTimersAsync();
|
|
158
156
|
});
|
|
159
157
|
|
|
160
158
|
expect(handleChange).not.toHaveBeenCalled();
|
|
161
159
|
|
|
162
|
-
|
|
160
|
+
userEvent.keyboard(text);
|
|
163
161
|
|
|
164
162
|
const value = new Date(initialValue);
|
|
165
163
|
value.setMonth(initialValue.getMonth() + step);
|
|
166
164
|
expect(handleChange).toHaveBeenCalledWith(value);
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
userEvent.keyboard('{Escape}');
|
|
169
167
|
await act(async () => {
|
|
170
168
|
await jest.runOnlyPendingTimersAsync();
|
|
171
169
|
});
|
|
@@ -180,7 +178,7 @@ describe('DateLookup', () => {
|
|
|
180
178
|
const handleChange = jest.fn();
|
|
181
179
|
await setupAndOpenWithMouse({ min, onChange: handleChange });
|
|
182
180
|
|
|
183
|
-
|
|
181
|
+
userEvent.keyboard('{ArrowLeft}{ArrowLeft}');
|
|
184
182
|
|
|
185
183
|
expect(handleChange).toHaveBeenCalledWith(min);
|
|
186
184
|
});
|
|
@@ -191,7 +189,7 @@ describe('DateLookup', () => {
|
|
|
191
189
|
const handleChange = jest.fn();
|
|
192
190
|
await setupAndOpenWithMouse({ max, onChange: handleChange });
|
|
193
191
|
|
|
194
|
-
|
|
192
|
+
userEvent.keyboard('{ArrowRight}{ArrowRight}');
|
|
195
193
|
|
|
196
194
|
expect(handleChange).toHaveBeenCalledWith(max);
|
|
197
195
|
});
|
|
@@ -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,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StoryFn } from '@storybook/react';
|
|
2
2
|
import { expect, userEvent, within } from '@storybook/test';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
|
|
@@ -9,7 +9,9 @@ export default {
|
|
|
9
9
|
title: 'Forms/DateLookup/Tests',
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type Story = StoryFn<typeof DateLookup>;
|
|
13
|
+
|
|
14
|
+
const Template: Story = () => {
|
|
13
15
|
const [value, setValue] = useState<Date | null>(new Date(1987, 0, 10, 12, 0, 0));
|
|
14
16
|
|
|
15
17
|
return (
|
|
@@ -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
package/src/info/Info.story.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { lorem10, storyConfig } from '../test-utils';
|
|
|
5
5
|
|
|
6
6
|
import Info, { InfoPresentation } from '.';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const meta = {
|
|
9
9
|
component: Info,
|
|
10
10
|
title: 'Dialogs/Info',
|
|
11
11
|
args: {
|
|
@@ -20,16 +20,18 @@ export default {
|
|
|
20
20
|
),
|
|
21
21
|
} satisfies Meta<typeof Info>;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
export default meta;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
26
|
+
|
|
27
|
+
export const Basic = storyConfig<typeof meta>(
|
|
26
28
|
{},
|
|
27
29
|
{
|
|
28
30
|
variants: ['default', 'dark', 'rtl'],
|
|
29
31
|
},
|
|
30
32
|
);
|
|
31
33
|
|
|
32
|
-
export const OpenedPopover
|
|
34
|
+
export const OpenedPopover = {
|
|
33
35
|
parameters: {
|
|
34
36
|
chromatic: {
|
|
35
37
|
delay: 1000,
|
|
@@ -39,15 +41,19 @@ export const OpenedPopover: Story = {
|
|
|
39
41
|
const canvas = within(canvasElement);
|
|
40
42
|
await userEvent.click(canvas.getByRole('button'));
|
|
41
43
|
},
|
|
42
|
-
};
|
|
44
|
+
} satisfies Story;
|
|
43
45
|
|
|
44
|
-
export const OpenedPopoverMobile
|
|
46
|
+
export const OpenedPopoverMobile = storyConfig(OpenedPopover, {
|
|
47
|
+
variants: ['mobile'],
|
|
48
|
+
});
|
|
45
49
|
|
|
46
|
-
export const OpenedModal
|
|
50
|
+
export const OpenedModal = {
|
|
47
51
|
...OpenedPopover,
|
|
48
52
|
args: {
|
|
49
53
|
presentation: InfoPresentation.MODAL,
|
|
50
54
|
},
|
|
51
|
-
};
|
|
55
|
+
} satisfies Story;
|
|
52
56
|
|
|
53
|
-
export const OpenedModalMobile
|
|
57
|
+
export const OpenedModalMobile = storyConfig(OpenedModal, {
|
|
58
|
+
variants: ['mobile'],
|
|
59
|
+
});
|
package/src/info/Info.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import Popover, { PopoverPreferredPlacement } from '../popover';
|
|
|
10
10
|
import messages from './Info.messages';
|
|
11
11
|
import { InfoPresentation } from './infoPresentations';
|
|
12
12
|
|
|
13
|
-
export interface
|
|
13
|
+
export interface InfoProps {
|
|
14
14
|
'aria-label'?: string;
|
|
15
15
|
/**
|
|
16
16
|
* Extra classes applied to Info
|
|
@@ -48,7 +48,7 @@ const Info = ({
|
|
|
48
48
|
title = undefined,
|
|
49
49
|
'aria-label': ariaLabel,
|
|
50
50
|
preferredPlacement = Position.BOTTOM,
|
|
51
|
-
}:
|
|
51
|
+
}: InfoProps) => {
|
|
52
52
|
const intl = useIntl();
|
|
53
53
|
const [open, setOpen] = useState(false);
|
|
54
54
|
ariaLabel ??= intl.formatMessage(messages.ariaLabel);
|
package/src/info/index.ts
CHANGED