@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-6ad430a",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"@storybook/test": "^7.6.19",
|
|
67
67
|
"@storybook/theming": "^7.6.19",
|
|
68
68
|
"@storybook/types": "^7.6.19",
|
|
69
|
-
"@testing-library/dom": "^
|
|
70
|
-
"@testing-library/jest-dom": "^
|
|
71
|
-
"@testing-library/react": "^
|
|
72
|
-
"@testing-library/user-event": "^
|
|
69
|
+
"@testing-library/dom": "^8.20.1",
|
|
70
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
71
|
+
"@testing-library/react": "^13.4.0",
|
|
72
|
+
"@testing-library/user-event": "^13.5.0",
|
|
73
73
|
"@transferwise/icons": "^3.7.0",
|
|
74
74
|
"@transferwise/neptune-tokens": "^8.9.2",
|
|
75
75
|
"@tsconfig/recommended": "^1.0.6",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"@types/react": "^18.3.3",
|
|
83
83
|
"@types/react-dom": "^18.3.0",
|
|
84
84
|
"@types/react-transition-group": "4.4.10",
|
|
85
|
+
"@types/testing-library__jest-dom": "^5.14.9",
|
|
85
86
|
"@wise/art": "^2.7.0",
|
|
86
87
|
"babel-plugin-formatjs": "^10.5.14",
|
|
87
88
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
@@ -94,8 +95,8 @@
|
|
|
94
95
|
"rollup": "^4.17.2",
|
|
95
96
|
"storybook": "^7.6.19",
|
|
96
97
|
"@transferwise/less-config": "3.1.0",
|
|
97
|
-
"@
|
|
98
|
-
"@
|
|
98
|
+
"@transferwise/neptune-css": "14.10.0",
|
|
99
|
+
"@wise/components-theming": "1.3.0"
|
|
99
100
|
},
|
|
100
101
|
"peerDependencies": {
|
|
101
102
|
"@transferwise/icons": "^3.7.0",
|
|
@@ -49,25 +49,25 @@ describe('Accordion', () => {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
describe('open and close', () => {
|
|
52
|
-
it('can open and close an item when clicked',
|
|
52
|
+
it('can open and close an item when clicked', () => {
|
|
53
53
|
const item = items[0];
|
|
54
54
|
render(<Accordion items={items} />);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
userEvent.click(screen.getByRole('button', { name: item.title }));
|
|
57
57
|
expect(screen.getByText(item.content)).toBeInTheDocument();
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
userEvent.click(screen.getByRole('button', { name: item.title }));
|
|
60
60
|
expect(screen.queryByText(item.content)).not.toBeInTheDocument();
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
describe('onClick', () => {
|
|
65
|
-
it('calls onClick when an item is clicked',
|
|
65
|
+
it('calls onClick when an item is clicked', () => {
|
|
66
66
|
const onClick = jest.fn();
|
|
67
67
|
|
|
68
68
|
render(<Accordion items={items} onClick={onClick} />);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
userEvent.click(screen.getAllByRole('button')[0]);
|
|
71
71
|
|
|
72
72
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
73
73
|
expect(onClick).toHaveBeenCalledWith(0);
|
|
@@ -39,12 +39,12 @@ describe('AccordionItem', () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
describe('onClick', () => {
|
|
42
|
-
it('calls onClick when item is clicked',
|
|
42
|
+
it('calls onClick when item is clicked', () => {
|
|
43
43
|
const onClick = jest.fn();
|
|
44
44
|
|
|
45
45
|
render(<AccordionItem {...props} onClick={onClick} />);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
userEvent.click(screen.getByRole('button'));
|
|
48
48
|
|
|
49
49
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
50
50
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
1
2
|
import { render, screen, userEvent } from '../test-utils';
|
|
2
3
|
|
|
3
4
|
import ActionButton from '.';
|
|
@@ -39,17 +40,17 @@ describe('ActionButton', () => {
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
describe('onClick', () => {
|
|
42
|
-
it('calls onClick when clicked',
|
|
43
|
+
it('calls onClick when clicked', () => {
|
|
43
44
|
const onClick = jest.fn();
|
|
44
45
|
render(<ActionButton {...props} onClick={onClick} />);
|
|
45
|
-
|
|
46
|
+
userEvent.click(screen.getByRole('button'));
|
|
46
47
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
it('does not call onClick when clicked if disabled',
|
|
50
|
+
it('does not call onClick when clicked if disabled', () => {
|
|
50
51
|
const onClick = jest.fn();
|
|
51
52
|
render(<ActionButton {...props} disabled onClick={onClick} />);
|
|
52
|
-
|
|
53
|
+
userEvent.click(screen.getByRole('button'));
|
|
53
54
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
54
55
|
});
|
|
55
56
|
});
|
package/src/alert/Alert.spec.tsx
CHANGED
|
@@ -175,14 +175,14 @@ describe('Alert', () => {
|
|
|
175
175
|
expect(element).not.toHaveAttribute('target');
|
|
176
176
|
});
|
|
177
177
|
|
|
178
|
-
it('sets text and onClick',
|
|
178
|
+
it('sets text and onClick', () => {
|
|
179
179
|
action = {
|
|
180
180
|
onClick: jest.fn(),
|
|
181
181
|
text: 'Learn more',
|
|
182
182
|
};
|
|
183
183
|
render(<Alert action={action} message={message} />);
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
userEvent.click(screen.getByText('Learn more'));
|
|
186
186
|
|
|
187
187
|
expect(action.onClick).toHaveBeenCalled();
|
|
188
188
|
});
|
|
@@ -246,12 +246,12 @@ describe('Alert', () => {
|
|
|
246
246
|
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
it('calls onDismiss when the close button is clicked',
|
|
249
|
+
it('calls onDismiss when the close button is clicked', () => {
|
|
250
250
|
const onDismiss = jest.fn();
|
|
251
251
|
|
|
252
252
|
render(<Alert message={message} onDismiss={onDismiss} />);
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
userEvent.click(screen.getByRole('button'));
|
|
255
255
|
|
|
256
256
|
expect(onDismiss).toHaveBeenCalledTimes(1);
|
|
257
257
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { createRef } from 'react';
|
|
3
3
|
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
4
5
|
import { ControlType, Type, Priority, Size } from '../common';
|
|
5
6
|
import { render, cleanup, screen, userEvent } from '../test-utils';
|
|
6
7
|
|
|
@@ -93,17 +94,17 @@ describe('Button', () => {
|
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
describe('onClick', () => {
|
|
96
|
-
it('calls onClick when clicked',
|
|
97
|
+
it('calls onClick when clicked', () => {
|
|
97
98
|
const onClick = jest.fn();
|
|
98
99
|
render(<Button {...props} onClick={onClick} />);
|
|
99
|
-
|
|
100
|
+
userEvent.click(screen.getByRole('button'));
|
|
100
101
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
it('does not call onClick when clicked if disabled',
|
|
104
|
+
it('does not call onClick when clicked if disabled', () => {
|
|
104
105
|
const onClick = jest.fn();
|
|
105
106
|
render(<Button {...props} disabled onClick={onClick} />);
|
|
106
|
-
|
|
107
|
+
userEvent.click(screen.getByRole('button'));
|
|
107
108
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
108
109
|
});
|
|
109
110
|
});
|
package/src/card/Card.spec.tsx
CHANGED
|
@@ -68,10 +68,10 @@ describe('Card', () => {
|
|
|
68
68
|
expect(screen.getByTestId(dataTestId)).toHaveClass('np-card--inactive');
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
it("doesn't call onClick when clicked",
|
|
71
|
+
it("doesn't call onClick when clicked", () => {
|
|
72
72
|
renderCard();
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
userEvent.click(screen.getByText(defaultProps.title));
|
|
75
75
|
|
|
76
76
|
expect(defaultProps.onClick).not.toHaveBeenCalled();
|
|
77
77
|
});
|
|
@@ -84,7 +84,7 @@ describe('Card', () => {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
describe('when there is children prop', () => {
|
|
87
|
-
it('calls on onClick with inverse of current isExpanded value when clicked',
|
|
87
|
+
it('calls on onClick with inverse of current isExpanded value when clicked', () => {
|
|
88
88
|
const onClick = jest.fn();
|
|
89
89
|
renderCard({
|
|
90
90
|
'aria-label': 'test',
|
|
@@ -94,7 +94,7 @@ describe('Card', () => {
|
|
|
94
94
|
onClick,
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
userEvent.click(screen.getByRole('button', { name: 'test' }));
|
|
98
98
|
expect(onClick).toHaveBeenCalledWith(true);
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -69,7 +69,7 @@ describe('Carousel', () => {
|
|
|
69
69
|
expect(screen.getByText('Get Quick Pay')).toBeInTheDocument();
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
it('allows user to scroll carousel to the right when at start',
|
|
72
|
+
it('allows user to scroll carousel to the right when at start', () => {
|
|
73
73
|
mockPositions(948, 903);
|
|
74
74
|
|
|
75
75
|
renderCarousel();
|
|
@@ -80,12 +80,12 @@ describe('Carousel', () => {
|
|
|
80
80
|
expect(scrollLeftButton).toBeDisabled();
|
|
81
81
|
expect(scrollRightButton).toBeEnabled();
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
userEvent.click(scrollRightButton);
|
|
84
84
|
|
|
85
85
|
expect(scrollBy).toHaveBeenCalledWith({ left: 300, behavior: 'smooth' });
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
it('allows user to scroll carousel to the left or right when in middle',
|
|
88
|
+
it('allows user to scroll carousel to the left or right when in middle', () => {
|
|
89
89
|
mockPositions(948, 903);
|
|
90
90
|
|
|
91
91
|
renderCarousel();
|
|
@@ -99,16 +99,16 @@ describe('Carousel', () => {
|
|
|
99
99
|
expect(scrollLeftButton).toBeEnabled();
|
|
100
100
|
expect(scrollRightButton).toBeEnabled();
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
userEvent.click(scrollLeftButton);
|
|
103
103
|
|
|
104
104
|
expect(scrollBy).toHaveBeenCalledWith({ left: -300, behavior: 'smooth' });
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
userEvent.click(scrollRightButton);
|
|
107
107
|
|
|
108
108
|
expect(scrollBy).toHaveBeenCalledWith({ left: 300, behavior: 'smooth' });
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
it('allows user to scroll carousel to the left when at end',
|
|
111
|
+
it('allows user to scroll carousel to the left when at end', () => {
|
|
112
112
|
mockPositions(948, 903);
|
|
113
113
|
|
|
114
114
|
renderCarousel();
|
|
@@ -122,7 +122,7 @@ describe('Carousel', () => {
|
|
|
122
122
|
expect(scrollLeftButton).toBeEnabled();
|
|
123
123
|
expect(scrollRightButton).toBeDisabled();
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
userEvent.click(scrollLeftButton);
|
|
126
126
|
|
|
127
127
|
expect(scrollBy).toHaveBeenCalledWith({ left: -300, behavior: 'smooth' });
|
|
128
128
|
});
|
|
@@ -142,23 +142,23 @@ describe('Carousel', () => {
|
|
|
142
142
|
expect(focusSpy).toHaveBeenCalledTimes(0);
|
|
143
143
|
expect(firstCard).toHaveClass('carousel__card--focused');
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
userEvent.click(yourWebsiteIndicator);
|
|
146
146
|
|
|
147
147
|
expect(focusSpy).toHaveBeenCalledTimes(1);
|
|
148
148
|
expect(secondCard).toHaveClass('carousel__card--focused');
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
userEvent.click(shopOrStallIndicator);
|
|
151
151
|
|
|
152
152
|
expect(focusSpy).toHaveBeenCalledTimes(2);
|
|
153
153
|
expect(thirdCard).toHaveClass('carousel__card--focused');
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
userEvent.click(yourInvoiceIndicator);
|
|
156
156
|
|
|
157
157
|
expect(focusSpy).toHaveBeenCalledTimes(3);
|
|
158
158
|
expect(firstCard).toHaveClass('carousel__card--focused');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
it('is focused on the first element and lets user navigate through them',
|
|
161
|
+
it('is focused on the first element and lets user navigate through them', () => {
|
|
162
162
|
renderCarousel();
|
|
163
163
|
|
|
164
164
|
const firstCard = getFirstCard();
|
|
@@ -170,27 +170,27 @@ describe('Carousel', () => {
|
|
|
170
170
|
firstCard.focus();
|
|
171
171
|
expect(firstCard).toHaveFocus();
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
userEvent.keyboard('{arrowright}');
|
|
174
174
|
|
|
175
175
|
expect(secondCard).toHaveFocus();
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
userEvent.keyboard('{arrowright}');
|
|
178
178
|
|
|
179
179
|
expect(thirdCard).toHaveFocus();
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
userEvent.keyboard('{arrowleft}');
|
|
182
182
|
|
|
183
183
|
expect(secondCard).toHaveFocus();
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
userEvent.keyboard('{arrowleft}');
|
|
186
186
|
|
|
187
187
|
expect(firstCard).toHaveFocus();
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
it('calls onClick when a card is clicked',
|
|
190
|
+
it('calls onClick when a card is clicked', () => {
|
|
191
191
|
renderCarousel();
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
userEvent.click(getFirstCard());
|
|
194
194
|
|
|
195
195
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
196
196
|
expect(yourInvoiceOnClick).toHaveBeenCalledTimes(1);
|
package/src/chips/Chips.spec.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
1
2
|
import { Plus } from '@transferwise/icons';
|
|
2
3
|
|
|
3
4
|
import { ControlType, Priority } from '../common';
|
|
@@ -53,17 +54,17 @@ describe('CircularButton', () => {
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
describe('onClick', () => {
|
|
56
|
-
it('calls onClick when clicked',
|
|
57
|
+
it('calls onClick when clicked', () => {
|
|
57
58
|
const onClick = jest.fn();
|
|
58
59
|
render(<CircularButton {...props} onClick={onClick} />);
|
|
59
|
-
|
|
60
|
+
userEvent.click(screen.getByRole('button'));
|
|
60
61
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
it('does not call onClick when clicked if disabled',
|
|
64
|
+
it('does not call onClick when clicked if disabled', () => {
|
|
64
65
|
const onClick = jest.fn();
|
|
65
66
|
render(<CircularButton {...props} disabled onClick={onClick} />);
|
|
66
|
-
|
|
67
|
+
userEvent.click(screen.getByRole('button'));
|
|
67
68
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
68
69
|
});
|
|
69
70
|
});
|
|
@@ -21,7 +21,7 @@ describe('Radio button', () => {
|
|
|
21
21
|
expect(container).toMatchSnapshot();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('responds to user input',
|
|
24
|
+
it('responds to user input', () => {
|
|
25
25
|
const onChange = jest.fn();
|
|
26
26
|
render(
|
|
27
27
|
<label htmlFor="an-id">
|
|
@@ -29,7 +29,7 @@ describe('Radio button', () => {
|
|
|
29
29
|
</label>,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
userEvent.click(screen.getByLabelText('A radio'));
|
|
33
33
|
|
|
34
34
|
expect(onChange).toHaveBeenCalledWith('a-value');
|
|
35
35
|
});
|
|
@@ -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
|
});
|