@instructure/ui-number-input 10.19.2-snapshot-2 → 10.19.2-snapshot-4

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.
@@ -1,284 +0,0 @@
1
- var _NumberInput, _NumberInput2, _NumberInput3, _NumberInput4, _IconZoomInLine, _IconZoomOutLine;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
26
- import { render, screen, waitFor } from '@testing-library/react';
27
- import userEvent from '@testing-library/user-event';
28
- import { vi } from 'vitest';
29
- import { runAxeCheck } from '@instructure/ui-axe-check';
30
- import '@testing-library/jest-dom';
31
- import { NumberInput } from '../index';
32
- import NumberInputExamples from '../__examples__/NumberInput.examples';
33
- // eslint-disable-next-line no-restricted-imports
34
- import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests';
35
- import { IconZoomInLine, IconZoomOutLine } from '@instructure/ui-icons';
36
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
37
- describe('<NumberInput />', () => {
38
- let consoleWarningMock;
39
- let consoleErrorMock;
40
- beforeEach(() => {
41
- // Mocking console to prevent test output pollution
42
- consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
43
- consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
44
- });
45
- afterEach(() => {
46
- consoleWarningMock.mockRestore();
47
- consoleErrorMock.mockRestore();
48
- });
49
- it('sets value on the input', async () => {
50
- const onChange = vi.fn();
51
- render(_jsx(NumberInput, {
52
- renderLabel: "Label",
53
- onChange: onChange,
54
- value: "42"
55
- }));
56
- const input = screen.getByRole('spinbutton');
57
- expect(input).toHaveValue(42);
58
- });
59
- it('should accept a number for the value', async () => {
60
- const onChange = vi.fn();
61
- render(_jsx(NumberInput, {
62
- renderLabel: "Label",
63
- onChange: onChange,
64
- value: 42
65
- }));
66
- const input = screen.getByRole('spinbutton');
67
- expect(input).toHaveValue(42);
68
- });
69
- it('displays the label', async () => {
70
- const _render = render(_NumberInput || (_NumberInput = _jsx(NumberInput, {
71
- renderLabel: "Label"
72
- }))),
73
- container = _render.container;
74
- const label = container.querySelector('span[class$="-formFieldLayout__label"]');
75
- expect(label).toHaveTextContent('Label');
76
- });
77
- it('passes the input element to inputRef', async () => {
78
- const inputRef = vi.fn();
79
- render(_jsx(NumberInput, {
80
- renderLabel: "Label",
81
- inputRef: inputRef
82
- }));
83
- const input = screen.getByRole('spinbutton');
84
- expect(inputRef).toHaveBeenCalledTimes(1);
85
- expect(inputRef).toHaveBeenCalledWith(input);
86
- });
87
- it('passes change events to onChange handler', async () => {
88
- const onChange = vi.fn();
89
- render(_jsx(NumberInput, {
90
- renderLabel: "Label",
91
- onChange: onChange
92
- }));
93
- const input = screen.getByRole('spinbutton');
94
- userEvent.type(input, '5');
95
- await waitFor(() => {
96
- const event = onChange.mock.calls[0][0];
97
- const args = onChange.mock.calls[0][1];
98
- expect(onChange).toHaveBeenCalledTimes(1);
99
- expect(args).toBe('5');
100
- expect(event.target.value).toBe('5');
101
- });
102
- });
103
- it('passes keyboard events to the onKeyDown handler', async () => {
104
- const onKeyDown = vi.fn();
105
- render(_jsx(NumberInput, {
106
- renderLabel: "Label",
107
- onKeyDown: onKeyDown
108
- }));
109
- const input = screen.getByRole('spinbutton');
110
- userEvent.type(input, '5');
111
- await waitFor(() => {
112
- expect(onKeyDown).toHaveBeenCalledTimes(1);
113
- });
114
- });
115
- it('passes blur events to onBlur handler', async () => {
116
- const onBlur = vi.fn();
117
- render(_jsx(NumberInput, {
118
- renderLabel: "Label",
119
- onBlur: onBlur
120
- }));
121
- userEvent.tab();
122
- userEvent.tab();
123
- await waitFor(() => {
124
- expect(onBlur).toHaveBeenCalledTimes(1);
125
- });
126
- });
127
- it('passes focus events to onFocus handler', async () => {
128
- const onFocus = vi.fn();
129
- render(_jsx(NumberInput, {
130
- renderLabel: "Label",
131
- onFocus: onFocus
132
- }));
133
- const input = screen.getByRole('spinbutton');
134
- input.focus();
135
- await waitFor(() => {
136
- expect(onFocus).toHaveBeenCalledTimes(1);
137
- });
138
- });
139
- it('shows arrow spinbuttons by default', async () => {
140
- const _render2 = render(_NumberInput2 || (_NumberInput2 = _jsx(NumberInput, {
141
- renderLabel: "Label"
142
- }))),
143
- container = _render2.container;
144
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
145
- expect(buttons).toHaveLength(2);
146
- });
147
- it('hides arrow spinbuttons when showArrows is false', async () => {
148
- const _render3 = render(_NumberInput3 || (_NumberInput3 = _jsx(NumberInput, {
149
- renderLabel: "Label",
150
- showArrows: false
151
- }))),
152
- container = _render3.container;
153
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
154
- expect(buttons).toHaveLength(0);
155
- });
156
- it('calls onIncrement when up arrow spinbutton is clicked', async () => {
157
- const onIncrement = vi.fn();
158
- const _render4 = render(_jsx(NumberInput, {
159
- renderLabel: "Label",
160
- onIncrement: onIncrement
161
- })),
162
- container = _render4.container;
163
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
164
- userEvent.click(buttons[0]);
165
- await waitFor(() => {
166
- expect(onIncrement).toHaveBeenCalledTimes(1);
167
- });
168
- });
169
- it('does not call onIncrement when `interaction` is set to readonly', async () => {
170
- const onIncrement = vi.fn();
171
- const _render5 = render(_jsx(NumberInput, {
172
- renderLabel: "Label",
173
- interaction: "readonly",
174
- onIncrement: onIncrement
175
- })),
176
- container = _render5.container;
177
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
178
- userEvent.click(buttons[0]);
179
- await waitFor(() => {
180
- expect(onIncrement).toHaveBeenCalledTimes(0);
181
- });
182
- });
183
- it('does not call onIncrement when `readOnly` is set', async () => {
184
- const onIncrement = vi.fn();
185
- const _render6 = render(_jsx(NumberInput, {
186
- renderLabel: "Label",
187
- readOnly: true,
188
- onIncrement: onIncrement
189
- })),
190
- container = _render6.container;
191
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
192
- userEvent.click(buttons[0]);
193
- await waitFor(() => {
194
- expect(onIncrement).toHaveBeenCalledTimes(0);
195
- });
196
- });
197
- it('calls onDecrement when down arrow spinbutton is clicked', async () => {
198
- const onDecrement = vi.fn();
199
- const _render7 = render(_jsx(NumberInput, {
200
- renderLabel: "Label",
201
- onDecrement: onDecrement
202
- })),
203
- container = _render7.container;
204
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
205
- userEvent.click(buttons[1]);
206
- await waitFor(() => {
207
- expect(onDecrement).toHaveBeenCalledTimes(1);
208
- });
209
- });
210
- it('does not call onDecrement when `interaction` is set to readonly', async () => {
211
- const onDecrement = vi.fn();
212
- const _render8 = render(_jsx(NumberInput, {
213
- renderLabel: "Label",
214
- interaction: "readonly",
215
- onDecrement: onDecrement
216
- })),
217
- container = _render8.container;
218
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
219
- userEvent.click(buttons[1]);
220
- await waitFor(() => {
221
- expect(onDecrement).toHaveBeenCalledTimes(0);
222
- });
223
- });
224
- it('does not call onDecrement when `readOnly` is set', async () => {
225
- const onDecrement = vi.fn();
226
- const _render9 = render(_jsx(NumberInput, {
227
- renderLabel: "Label",
228
- readOnly: true,
229
- onDecrement: onDecrement
230
- })),
231
- container = _render9.container;
232
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
233
- userEvent.click(buttons[1]);
234
- await waitFor(() => {
235
- expect(onDecrement).toHaveBeenCalledTimes(0);
236
- });
237
- });
238
- it('puts inputMode prop to input', async () => {
239
- render(_NumberInput4 || (_NumberInput4 = _jsx(NumberInput, {
240
- renderLabel: "Label",
241
- inputMode: "decimal"
242
- })));
243
- const input = screen.getByRole('spinbutton');
244
- expect(input).toHaveAttribute('inputMode', 'decimal');
245
- });
246
- describe('with generated examples', () => {
247
- const generatedComponents = generateA11yTests(NumberInput, NumberInputExamples);
248
- for (const component of generatedComponents) {
249
- it(component.description, async () => {
250
- const _render10 = render(component.content),
251
- container = _render10.container;
252
- const axeCheck = await runAxeCheck(container);
253
- expect(axeCheck).toBe(true);
254
- });
255
- }
256
- });
257
- it('renders custom interactive icons', async () => {
258
- const onDecrement = vi.fn();
259
- const onIncrement = vi.fn();
260
- const _render11 = render(_jsx(NumberInput, {
261
- renderLabel: "Label",
262
- onIncrement: onIncrement,
263
- onDecrement: onDecrement,
264
- renderIcons: {
265
- increase: _IconZoomInLine || (_IconZoomInLine = _jsx(IconZoomInLine, {})),
266
- decrease: _IconZoomOutLine || (_IconZoomOutLine = _jsx(IconZoomOutLine, {}))
267
- }
268
- })),
269
- container = _render11.container;
270
- const zoomInIcon = container.querySelector('svg[name="IconZoomIn"]');
271
- const zoomOutIcon = container.querySelector('svg[name="IconZoomOut"]');
272
- expect(zoomInIcon).toBeInTheDocument();
273
- expect(zoomOutIcon).toBeInTheDocument();
274
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
275
- userEvent.click(buttons[0]);
276
- await waitFor(() => {
277
- expect(onIncrement).toHaveBeenCalledTimes(1);
278
- });
279
- userEvent.click(buttons[1]);
280
- await waitFor(() => {
281
- expect(onDecrement).toHaveBeenCalledTimes(1);
282
- });
283
- });
284
- });
@@ -1,287 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("@testing-library/react");
5
- var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
6
- var _vitest = require("vitest");
7
- var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
8
- require("@testing-library/jest-dom");
9
- var _index = require("../index");
10
- var _NumberInput5 = _interopRequireDefault(require("../__examples__/NumberInput.examples"));
11
- var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
12
- var _IconZoomInLine2 = require("@instructure/ui-icons/lib/IconZoomInLine.js");
13
- var _IconZoomOutLine2 = require("@instructure/ui-icons/lib/IconZoomOutLine.js");
14
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
- var _NumberInput, _NumberInput2, _NumberInput3, _NumberInput4, _IconZoomInLine, _IconZoomOutLine;
16
- /*
17
- * The MIT License (MIT)
18
- *
19
- * Copyright (c) 2015 - present Instructure, Inc.
20
- *
21
- * Permission is hereby granted, free of charge, to any person obtaining a copy
22
- * of this software and associated documentation files (the "Software"), to deal
23
- * in the Software without restriction, including without limitation the rights
24
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
- * copies of the Software, and to permit persons to whom the Software is
26
- * furnished to do so, subject to the following conditions:
27
- *
28
- * The above copyright notice and this permission notice shall be included in all
29
- * copies or substantial portions of the Software.
30
- *
31
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
- * SOFTWARE.
38
- */
39
- // eslint-disable-next-line no-restricted-imports
40
- describe('<NumberInput />', () => {
41
- let consoleWarningMock;
42
- let consoleErrorMock;
43
- beforeEach(() => {
44
- // Mocking console to prevent test output pollution
45
- consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
46
- consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
47
- });
48
- afterEach(() => {
49
- consoleWarningMock.mockRestore();
50
- consoleErrorMock.mockRestore();
51
- });
52
- it('sets value on the input', async () => {
53
- const onChange = _vitest.vi.fn();
54
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
55
- renderLabel: "Label",
56
- onChange: onChange,
57
- value: "42"
58
- }));
59
- const input = _react.screen.getByRole('spinbutton');
60
- expect(input).toHaveValue(42);
61
- });
62
- it('should accept a number for the value', async () => {
63
- const onChange = _vitest.vi.fn();
64
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
65
- renderLabel: "Label",
66
- onChange: onChange,
67
- value: 42
68
- }));
69
- const input = _react.screen.getByRole('spinbutton');
70
- expect(input).toHaveValue(42);
71
- });
72
- it('displays the label', async () => {
73
- const _render = (0, _react.render)(_NumberInput || (_NumberInput = (0, _jsxRuntime.jsx)(_index.NumberInput, {
74
- renderLabel: "Label"
75
- }))),
76
- container = _render.container;
77
- const label = container.querySelector('span[class$="-formFieldLayout__label"]');
78
- expect(label).toHaveTextContent('Label');
79
- });
80
- it('passes the input element to inputRef', async () => {
81
- const inputRef = _vitest.vi.fn();
82
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
83
- renderLabel: "Label",
84
- inputRef: inputRef
85
- }));
86
- const input = _react.screen.getByRole('spinbutton');
87
- expect(inputRef).toHaveBeenCalledTimes(1);
88
- expect(inputRef).toHaveBeenCalledWith(input);
89
- });
90
- it('passes change events to onChange handler', async () => {
91
- const onChange = _vitest.vi.fn();
92
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
93
- renderLabel: "Label",
94
- onChange: onChange
95
- }));
96
- const input = _react.screen.getByRole('spinbutton');
97
- _userEvent.default.type(input, '5');
98
- await (0, _react.waitFor)(() => {
99
- const event = onChange.mock.calls[0][0];
100
- const args = onChange.mock.calls[0][1];
101
- expect(onChange).toHaveBeenCalledTimes(1);
102
- expect(args).toBe('5');
103
- expect(event.target.value).toBe('5');
104
- });
105
- });
106
- it('passes keyboard events to the onKeyDown handler', async () => {
107
- const onKeyDown = _vitest.vi.fn();
108
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
109
- renderLabel: "Label",
110
- onKeyDown: onKeyDown
111
- }));
112
- const input = _react.screen.getByRole('spinbutton');
113
- _userEvent.default.type(input, '5');
114
- await (0, _react.waitFor)(() => {
115
- expect(onKeyDown).toHaveBeenCalledTimes(1);
116
- });
117
- });
118
- it('passes blur events to onBlur handler', async () => {
119
- const onBlur = _vitest.vi.fn();
120
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
121
- renderLabel: "Label",
122
- onBlur: onBlur
123
- }));
124
- _userEvent.default.tab();
125
- _userEvent.default.tab();
126
- await (0, _react.waitFor)(() => {
127
- expect(onBlur).toHaveBeenCalledTimes(1);
128
- });
129
- });
130
- it('passes focus events to onFocus handler', async () => {
131
- const onFocus = _vitest.vi.fn();
132
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
133
- renderLabel: "Label",
134
- onFocus: onFocus
135
- }));
136
- const input = _react.screen.getByRole('spinbutton');
137
- input.focus();
138
- await (0, _react.waitFor)(() => {
139
- expect(onFocus).toHaveBeenCalledTimes(1);
140
- });
141
- });
142
- it('shows arrow spinbuttons by default', async () => {
143
- const _render2 = (0, _react.render)(_NumberInput2 || (_NumberInput2 = (0, _jsxRuntime.jsx)(_index.NumberInput, {
144
- renderLabel: "Label"
145
- }))),
146
- container = _render2.container;
147
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
148
- expect(buttons).toHaveLength(2);
149
- });
150
- it('hides arrow spinbuttons when showArrows is false', async () => {
151
- const _render3 = (0, _react.render)(_NumberInput3 || (_NumberInput3 = (0, _jsxRuntime.jsx)(_index.NumberInput, {
152
- renderLabel: "Label",
153
- showArrows: false
154
- }))),
155
- container = _render3.container;
156
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
157
- expect(buttons).toHaveLength(0);
158
- });
159
- it('calls onIncrement when up arrow spinbutton is clicked', async () => {
160
- const onIncrement = _vitest.vi.fn();
161
- const _render4 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
162
- renderLabel: "Label",
163
- onIncrement: onIncrement
164
- })),
165
- container = _render4.container;
166
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
167
- _userEvent.default.click(buttons[0]);
168
- await (0, _react.waitFor)(() => {
169
- expect(onIncrement).toHaveBeenCalledTimes(1);
170
- });
171
- });
172
- it('does not call onIncrement when `interaction` is set to readonly', async () => {
173
- const onIncrement = _vitest.vi.fn();
174
- const _render5 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
175
- renderLabel: "Label",
176
- interaction: "readonly",
177
- onIncrement: onIncrement
178
- })),
179
- container = _render5.container;
180
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
181
- _userEvent.default.click(buttons[0]);
182
- await (0, _react.waitFor)(() => {
183
- expect(onIncrement).toHaveBeenCalledTimes(0);
184
- });
185
- });
186
- it('does not call onIncrement when `readOnly` is set', async () => {
187
- const onIncrement = _vitest.vi.fn();
188
- const _render6 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
189
- renderLabel: "Label",
190
- readOnly: true,
191
- onIncrement: onIncrement
192
- })),
193
- container = _render6.container;
194
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
195
- _userEvent.default.click(buttons[0]);
196
- await (0, _react.waitFor)(() => {
197
- expect(onIncrement).toHaveBeenCalledTimes(0);
198
- });
199
- });
200
- it('calls onDecrement when down arrow spinbutton is clicked', async () => {
201
- const onDecrement = _vitest.vi.fn();
202
- const _render7 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
203
- renderLabel: "Label",
204
- onDecrement: onDecrement
205
- })),
206
- container = _render7.container;
207
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
208
- _userEvent.default.click(buttons[1]);
209
- await (0, _react.waitFor)(() => {
210
- expect(onDecrement).toHaveBeenCalledTimes(1);
211
- });
212
- });
213
- it('does not call onDecrement when `interaction` is set to readonly', async () => {
214
- const onDecrement = _vitest.vi.fn();
215
- const _render8 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
216
- renderLabel: "Label",
217
- interaction: "readonly",
218
- onDecrement: onDecrement
219
- })),
220
- container = _render8.container;
221
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
222
- _userEvent.default.click(buttons[1]);
223
- await (0, _react.waitFor)(() => {
224
- expect(onDecrement).toHaveBeenCalledTimes(0);
225
- });
226
- });
227
- it('does not call onDecrement when `readOnly` is set', async () => {
228
- const onDecrement = _vitest.vi.fn();
229
- const _render9 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
230
- renderLabel: "Label",
231
- readOnly: true,
232
- onDecrement: onDecrement
233
- })),
234
- container = _render9.container;
235
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
236
- _userEvent.default.click(buttons[1]);
237
- await (0, _react.waitFor)(() => {
238
- expect(onDecrement).toHaveBeenCalledTimes(0);
239
- });
240
- });
241
- it('puts inputMode prop to input', async () => {
242
- (0, _react.render)(_NumberInput4 || (_NumberInput4 = (0, _jsxRuntime.jsx)(_index.NumberInput, {
243
- renderLabel: "Label",
244
- inputMode: "decimal"
245
- })));
246
- const input = _react.screen.getByRole('spinbutton');
247
- expect(input).toHaveAttribute('inputMode', 'decimal');
248
- });
249
- describe('with generated examples', () => {
250
- const generatedComponents = (0, _generateA11yTests.generateA11yTests)(_index.NumberInput, _NumberInput5.default);
251
- for (const component of generatedComponents) {
252
- it(component.description, async () => {
253
- const _render10 = (0, _react.render)(component.content),
254
- container = _render10.container;
255
- const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
256
- expect(axeCheck).toBe(true);
257
- });
258
- }
259
- });
260
- it('renders custom interactive icons', async () => {
261
- const onDecrement = _vitest.vi.fn();
262
- const onIncrement = _vitest.vi.fn();
263
- const _render11 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.NumberInput, {
264
- renderLabel: "Label",
265
- onIncrement: onIncrement,
266
- onDecrement: onDecrement,
267
- renderIcons: {
268
- increase: _IconZoomInLine || (_IconZoomInLine = (0, _jsxRuntime.jsx)(_IconZoomInLine2.IconZoomInLine, {})),
269
- decrease: _IconZoomOutLine || (_IconZoomOutLine = (0, _jsxRuntime.jsx)(_IconZoomOutLine2.IconZoomOutLine, {}))
270
- }
271
- })),
272
- container = _render11.container;
273
- const zoomInIcon = container.querySelector('svg[name="IconZoomIn"]');
274
- const zoomOutIcon = container.querySelector('svg[name="IconZoomOut"]');
275
- expect(zoomInIcon).toBeInTheDocument();
276
- expect(zoomOutIcon).toBeInTheDocument();
277
- const buttons = container.querySelectorAll('button[class$="-numberInput_arrow');
278
- _userEvent.default.click(buttons[0]);
279
- await (0, _react.waitFor)(() => {
280
- expect(onIncrement).toHaveBeenCalledTimes(1);
281
- });
282
- _userEvent.default.click(buttons[1]);
283
- await (0, _react.waitFor)(() => {
284
- expect(onDecrement).toHaveBeenCalledTimes(1);
285
- });
286
- });
287
- });