@instructure/ui-date-input 10.16.1-pr-snapshot-1744893671793 → 10.16.1-snapshot-0
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/CHANGELOG.md +1 -1
- package/es/DateInput/__new-tests__/DateInput.test.js +129 -167
- package/es/DateInput/index.js +58 -71
- package/es/DateInput2/__new-tests__/DateInput2.test.js +19 -20
- package/es/DateInput2/index.js +35 -37
- package/lib/DateInput/__new-tests__/DateInput.test.js +191 -228
- package/lib/DateInput/index.js +58 -70
- package/lib/DateInput2/__new-tests__/DateInput2.test.js +20 -20
- package/lib/DateInput2/index.js +35 -37
- package/package.json +20 -20
- package/src/DateInput/__new-tests__/DateInput.test.tsx +1 -1
- package/src/DateInput/index.tsx +3 -2
- package/src/DateInput/props.ts +1 -1
- package/src/DateInput2/__new-tests__/DateInput2.test.tsx +1 -1
- package/src/DateInput2/index.tsx +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateInput/index.d.ts +17 -15
- package/types/DateInput/index.d.ts.map +1 -1
- package/types/DateInput/props.d.ts +1 -1
- package/types/DateInput/props.d.ts.map +1 -1
- package/types/DateInput2/index.d.ts +2 -1
- package/types/DateInput2/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
-
## [10.16.1-
|
6
|
+
## [10.16.1-snapshot-0](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-0) (2025-04-15)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-date-input
|
9
9
|
|
@@ -22,7 +22,7 @@ var _Calendar$Day, _button, _button2, _Calendar$Day2, _Calendar$Day3;
|
|
22
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
23
|
* SOFTWARE.
|
24
24
|
*/
|
25
|
-
|
25
|
+
import React from 'react';
|
26
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
27
27
|
import { vi } from 'vitest';
|
28
28
|
import userEvent from '@testing-library/user-event';
|
@@ -34,18 +34,17 @@ import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
34
34
|
import { Calendar } from '@instructure/ui-calendar';
|
35
35
|
import Examples from '../__examples__/DateInput.examples';
|
36
36
|
import { DateInput } from '../index';
|
37
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
38
37
|
describe('<DateInput />', () => {
|
39
38
|
const weekdayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
40
39
|
const generateDays = (count = Calendar.DAY_COUNT) => {
|
41
40
|
const days = [];
|
42
41
|
const date = new Date('2019-07-28');
|
43
42
|
while (days.length < count) {
|
44
|
-
days.push(
|
43
|
+
days.push(/*#__PURE__*/React.createElement(Calendar.Day, {
|
44
|
+
key: date.toISOString(),
|
45
45
|
date: date.toISOString(),
|
46
|
-
label: date.toISOString()
|
47
|
-
|
48
|
-
}, date.toISOString()));
|
46
|
+
label: date.toISOString()
|
47
|
+
}, date.getDate()));
|
49
48
|
date.setDate(date.getDate() + 1);
|
50
49
|
}
|
51
50
|
return days;
|
@@ -62,12 +61,11 @@ describe('<DateInput />', () => {
|
|
62
61
|
consoleErrorMock.mockRestore();
|
63
62
|
});
|
64
63
|
it('should render an input and a calendar', async () => {
|
65
|
-
const _render = render(
|
64
|
+
const _render = render(/*#__PURE__*/React.createElement(DateInput, {
|
66
65
|
renderLabel: "date-input",
|
67
66
|
renderWeekdayLabels: weekdayLabels,
|
68
|
-
isShowingCalendar: true
|
69
|
-
|
70
|
-
})),
|
67
|
+
isShowingCalendar: true
|
68
|
+
}, generateDays())),
|
71
69
|
container = _render.container,
|
72
70
|
findByRole = _render.findByRole;
|
73
71
|
const dateInput = container.querySelector('input');
|
@@ -84,35 +82,32 @@ describe('<DateInput />', () => {
|
|
84
82
|
describe('input', () => {
|
85
83
|
it('should render a label', () => {
|
86
84
|
const labelText = 'label text';
|
87
|
-
render(
|
85
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
88
86
|
renderLabel: labelText,
|
89
|
-
renderWeekdayLabels: weekdayLabels
|
90
|
-
|
91
|
-
}));
|
87
|
+
renderWeekdayLabels: weekdayLabels
|
88
|
+
}, generateDays()));
|
92
89
|
const dateInput = screen.getByLabelText('label text');
|
93
90
|
expect(dateInput).toBeInTheDocument();
|
94
91
|
});
|
95
92
|
it('should set value', () => {
|
96
93
|
const value = 'January 5';
|
97
|
-
render(
|
94
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
98
95
|
renderLabel: "Choose date",
|
99
96
|
value: value,
|
100
97
|
onChange: vi.fn(),
|
101
|
-
renderWeekdayLabels: weekdayLabels
|
102
|
-
|
103
|
-
}));
|
98
|
+
renderWeekdayLabels: weekdayLabels
|
99
|
+
}, generateDays()));
|
104
100
|
const dateInput = screen.getByLabelText('Choose date');
|
105
101
|
expect(dateInput).toHaveValue(value);
|
106
102
|
});
|
107
103
|
it('should call onChange with the updated value', async () => {
|
108
104
|
const onChange = vi.fn();
|
109
105
|
const value = 'May 18, 2022';
|
110
|
-
render(
|
106
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
111
107
|
renderLabel: "Choose date",
|
112
108
|
renderWeekdayLabels: weekdayLabels,
|
113
|
-
onChange: onChange
|
114
|
-
|
115
|
-
}));
|
109
|
+
onChange: onChange
|
110
|
+
}, generateDays()));
|
116
111
|
const dateInput = screen.getByLabelText('Choose date');
|
117
112
|
fireEvent.change(dateInput, {
|
118
113
|
target: {
|
@@ -131,111 +126,101 @@ describe('<DateInput />', () => {
|
|
131
126
|
});
|
132
127
|
it('should call onBlur', () => {
|
133
128
|
const onBlur = vi.fn();
|
134
|
-
render(
|
129
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
135
130
|
renderLabel: "Choose date",
|
136
131
|
renderWeekdayLabels: weekdayLabels,
|
137
|
-
onBlur: onBlur
|
138
|
-
|
139
|
-
}));
|
132
|
+
onBlur: onBlur
|
133
|
+
}, generateDays()));
|
140
134
|
const dateInput = screen.getByLabelText('Choose date');
|
141
135
|
fireEvent.blur(dateInput);
|
142
136
|
expect(onBlur).toHaveBeenCalledTimes(1);
|
143
137
|
});
|
144
138
|
it('should correctly set interaction type', async () => {
|
145
|
-
const _render2 = render(
|
139
|
+
const _render2 = render(/*#__PURE__*/React.createElement(DateInput, {
|
146
140
|
renderLabel: "Choose date",
|
147
141
|
renderWeekdayLabels: weekdayLabels,
|
148
|
-
interaction: "disabled"
|
149
|
-
|
150
|
-
})),
|
142
|
+
interaction: "disabled"
|
143
|
+
}, generateDays())),
|
151
144
|
rerender = _render2.rerender;
|
152
145
|
const dateInput = screen.getByLabelText('Choose date');
|
153
146
|
expect(dateInput).toHaveAttribute('disabled');
|
154
|
-
rerender(
|
147
|
+
rerender(/*#__PURE__*/React.createElement(DateInput, {
|
155
148
|
renderLabel: "Choose date",
|
156
149
|
renderWeekdayLabels: weekdayLabels,
|
157
|
-
interaction: "readonly"
|
158
|
-
|
159
|
-
}));
|
150
|
+
interaction: "readonly"
|
151
|
+
}, generateDays()));
|
160
152
|
const dateInputAfterUpdate = screen.getByLabelText('Choose date');
|
161
153
|
await waitFor(() => {
|
162
154
|
expect(dateInputAfterUpdate).toHaveAttribute('readonly');
|
163
155
|
});
|
164
156
|
});
|
165
157
|
it('should correctly set disabled', () => {
|
166
|
-
render(
|
158
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
167
159
|
renderLabel: "Choose date",
|
168
160
|
renderWeekdayLabels: weekdayLabels,
|
169
|
-
disabled: true
|
170
|
-
|
171
|
-
}));
|
161
|
+
disabled: true
|
162
|
+
}, generateDays()));
|
172
163
|
const dateInput = screen.getByLabelText('Choose date');
|
173
164
|
expect(dateInput).toHaveAttribute('disabled');
|
174
165
|
});
|
175
166
|
it('should correctly set readOnly', () => {
|
176
|
-
render(
|
167
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
177
168
|
renderLabel: "Choose date",
|
178
169
|
renderWeekdayLabels: weekdayLabels,
|
179
|
-
readOnly: true
|
180
|
-
|
181
|
-
}));
|
170
|
+
readOnly: true
|
171
|
+
}, generateDays()));
|
182
172
|
const dateInput = screen.getByLabelText('Choose date');
|
183
173
|
expect(dateInput).toHaveAttribute('readOnly');
|
184
174
|
});
|
185
175
|
it('should set placeholder', () => {
|
186
176
|
const placeholder = 'Start typing to choose a date';
|
187
|
-
render(
|
177
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
188
178
|
renderLabel: "Choose date",
|
189
179
|
renderWeekdayLabels: weekdayLabels,
|
190
|
-
placeholder: placeholder
|
191
|
-
|
192
|
-
}));
|
180
|
+
placeholder: placeholder
|
181
|
+
}, generateDays()));
|
193
182
|
const dateInput = screen.getByLabelText('Choose date');
|
194
183
|
expect(dateInput).toHaveAttribute('placeholder', placeholder);
|
195
184
|
});
|
196
185
|
it('should be requireable', () => {
|
197
|
-
render(
|
186
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
198
187
|
renderLabel: "Choose date",
|
199
188
|
renderWeekdayLabels: weekdayLabels,
|
200
|
-
isRequired: true
|
201
|
-
|
202
|
-
}));
|
189
|
+
isRequired: true
|
190
|
+
}, generateDays()));
|
203
191
|
const dateInput = screen.getByLabelText('Choose date *');
|
204
192
|
expect(dateInput).toHaveAttribute('required');
|
205
193
|
});
|
206
194
|
it('should provide inputRef', () => {
|
207
195
|
const inputRef = vi.fn();
|
208
|
-
render(
|
196
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
209
197
|
renderLabel: "Choose date",
|
210
198
|
renderWeekdayLabels: weekdayLabels,
|
211
|
-
inputRef: inputRef
|
212
|
-
|
213
|
-
}));
|
199
|
+
inputRef: inputRef
|
200
|
+
}, generateDays()));
|
214
201
|
const dateInput = screen.getByLabelText('Choose date');
|
215
202
|
expect(inputRef).toHaveBeenCalledWith(dateInput);
|
216
203
|
});
|
217
204
|
it('should render messages', () => {
|
218
205
|
const text = 'The selected date is invalid';
|
219
|
-
const _render3 = render(
|
206
|
+
const _render3 = render(/*#__PURE__*/React.createElement(DateInput, {
|
220
207
|
renderLabel: "Choose date",
|
221
208
|
renderWeekdayLabels: weekdayLabels,
|
222
209
|
messages: [{
|
223
210
|
type: 'error',
|
224
211
|
text
|
225
|
-
}]
|
226
|
-
|
227
|
-
})),
|
212
|
+
}]
|
213
|
+
}, generateDays())),
|
228
214
|
container = _render3.container;
|
229
215
|
expect(container).toHaveTextContent(text);
|
230
216
|
});
|
231
217
|
it('should allow custom props to pass through', () => {
|
232
|
-
render(
|
218
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
233
219
|
renderLabel: "Choose date",
|
234
220
|
renderWeekdayLabels: weekdayLabels,
|
235
221
|
"data-custom-attr": "custom value",
|
236
|
-
name: "my name"
|
237
|
-
|
238
|
-
}));
|
222
|
+
name: "my name"
|
223
|
+
}, generateDays()));
|
239
224
|
const dateInput = screen.getByLabelText('Choose date');
|
240
225
|
expect(dateInput).toHaveAttribute('data-custom-attr', 'custom value');
|
241
226
|
expect(dateInput).toHaveAttribute('name', 'my name');
|
@@ -243,11 +228,10 @@ describe('<DateInput />', () => {
|
|
243
228
|
});
|
244
229
|
describe('Calendar', () => {
|
245
230
|
it('should show calendar when `isShowingCalendar` is set', async () => {
|
246
|
-
const _render4 = render(
|
231
|
+
const _render4 = render(/*#__PURE__*/React.createElement(DateInput, {
|
247
232
|
renderLabel: "Choose date",
|
248
|
-
renderWeekdayLabels: weekdayLabels
|
249
|
-
|
250
|
-
})),
|
233
|
+
renderWeekdayLabels: weekdayLabels
|
234
|
+
}, generateDays())),
|
251
235
|
rerender = _render4.rerender,
|
252
236
|
queryByRole = _render4.queryByRole;
|
253
237
|
const dateInput = screen.getByLabelText('Choose date');
|
@@ -256,12 +240,11 @@ describe('<DateInput />', () => {
|
|
256
240
|
expect(dateInput).toBeInTheDocument();
|
257
241
|
expect(calendarTable).not.toBeInTheDocument();
|
258
242
|
expect(calendarWrapper).not.toBeInTheDocument();
|
259
|
-
rerender(
|
243
|
+
rerender(/*#__PURE__*/React.createElement(DateInput, {
|
260
244
|
renderLabel: "Choose date",
|
261
245
|
renderWeekdayLabels: weekdayLabels,
|
262
|
-
isShowingCalendar: true
|
263
|
-
|
264
|
-
}));
|
246
|
+
isShowingCalendar: true
|
247
|
+
}, generateDays()));
|
265
248
|
const dateInputAfterUpdate = screen.getByLabelText('Choose date');
|
266
249
|
const calendarTableAfterUpdate = await queryByRole('listbox');
|
267
250
|
const calendarWrapperAfterUpdate = await document.querySelector('[id^="Selectable_"][id$="-list"]');
|
@@ -274,12 +257,11 @@ describe('<DateInput />', () => {
|
|
274
257
|
describe('onRequestShowCalendar', () => {
|
275
258
|
it('should call onRequestShowCalendar when label is clicked', async () => {
|
276
259
|
const onRequestShowCalendar = vi.fn();
|
277
|
-
const _render5 = render(
|
260
|
+
const _render5 = render(/*#__PURE__*/React.createElement(DateInput, {
|
278
261
|
renderLabel: "Choose date",
|
279
262
|
renderWeekdayLabels: weekdayLabels,
|
280
|
-
onRequestShowCalendar: onRequestShowCalendar
|
281
|
-
|
282
|
-
})),
|
263
|
+
onRequestShowCalendar: onRequestShowCalendar
|
264
|
+
}, generateDays())),
|
283
265
|
container = _render5.container;
|
284
266
|
const dateInput = container.querySelector('span[class$="-formFieldLayout__label"]');
|
285
267
|
expect(dateInput).toHaveTextContent('Choose date');
|
@@ -290,12 +272,11 @@ describe('<DateInput />', () => {
|
|
290
272
|
});
|
291
273
|
it('should call onRequestShowCalendar when input is clicked', async () => {
|
292
274
|
const onRequestShowCalendar = vi.fn();
|
293
|
-
const _render6 = render(
|
275
|
+
const _render6 = render(/*#__PURE__*/React.createElement(DateInput, {
|
294
276
|
renderLabel: "Choose date",
|
295
277
|
renderWeekdayLabels: weekdayLabels,
|
296
|
-
onRequestShowCalendar: onRequestShowCalendar
|
297
|
-
|
298
|
-
})),
|
278
|
+
onRequestShowCalendar: onRequestShowCalendar
|
279
|
+
}, generateDays())),
|
299
280
|
container = _render6.container;
|
300
281
|
const dateInput = container.querySelector('input');
|
301
282
|
await userEvent.click(dateInput);
|
@@ -305,12 +286,11 @@ describe('<DateInput />', () => {
|
|
305
286
|
});
|
306
287
|
it('should call onRequestShowCalendar when input receives space event', async () => {
|
307
288
|
const onRequestShowCalendar = vi.fn();
|
308
|
-
render(
|
289
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
309
290
|
renderLabel: "Choose date",
|
310
291
|
renderWeekdayLabels: weekdayLabels,
|
311
|
-
onRequestShowCalendar: onRequestShowCalendar
|
312
|
-
|
313
|
-
}));
|
292
|
+
onRequestShowCalendar: onRequestShowCalendar
|
293
|
+
}, generateDays()));
|
314
294
|
const dateInput = screen.getByLabelText('Choose date');
|
315
295
|
await userEvent.type(dateInput, '{space}');
|
316
296
|
await waitFor(() => {
|
@@ -319,13 +299,12 @@ describe('<DateInput />', () => {
|
|
319
299
|
});
|
320
300
|
it('should not call onRequestShowCalendar when input receives space event if calendar is already showing', async () => {
|
321
301
|
const onRequestShowCalendar = vi.fn();
|
322
|
-
render(
|
302
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
323
303
|
renderLabel: "Choose date",
|
324
304
|
renderWeekdayLabels: weekdayLabels,
|
325
305
|
onRequestShowCalendar: onRequestShowCalendar,
|
326
|
-
isShowingCalendar: true
|
327
|
-
|
328
|
-
}));
|
306
|
+
isShowingCalendar: true
|
307
|
+
}, generateDays()));
|
329
308
|
const dateInput = screen.getByLabelText('Choose date');
|
330
309
|
await userEvent.type(dateInput, '{space}');
|
331
310
|
await waitFor(() => {
|
@@ -334,12 +313,11 @@ describe('<DateInput />', () => {
|
|
334
313
|
});
|
335
314
|
it('should call onRequestShowCalendar when input receives down arrow event', async () => {
|
336
315
|
const onRequestShowCalendar = vi.fn();
|
337
|
-
render(
|
316
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
338
317
|
renderLabel: "Choose date",
|
339
318
|
renderWeekdayLabels: weekdayLabels,
|
340
|
-
onRequestShowCalendar: onRequestShowCalendar
|
341
|
-
|
342
|
-
}));
|
319
|
+
onRequestShowCalendar: onRequestShowCalendar
|
320
|
+
}, generateDays()));
|
343
321
|
const dateInput = screen.getByLabelText('Choose date');
|
344
322
|
await userEvent.type(dateInput, '{arrowdown}');
|
345
323
|
await waitFor(() => {
|
@@ -348,13 +326,12 @@ describe('<DateInput />', () => {
|
|
348
326
|
});
|
349
327
|
it('should not call onRequestShowCalendar when input receives down arrow event if calendar is already showing', async () => {
|
350
328
|
const onRequestShowCalendar = vi.fn();
|
351
|
-
render(
|
329
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
352
330
|
renderLabel: "Choose date",
|
353
331
|
renderWeekdayLabels: weekdayLabels,
|
354
332
|
onRequestShowCalendar: onRequestShowCalendar,
|
355
|
-
isShowingCalendar: true
|
356
|
-
|
357
|
-
}));
|
333
|
+
isShowingCalendar: true
|
334
|
+
}, generateDays()));
|
358
335
|
const dateInput = screen.getByLabelText('Choose date');
|
359
336
|
await userEvent.type(dateInput, '{arrowdown}');
|
360
337
|
await waitFor(() => {
|
@@ -363,12 +340,11 @@ describe('<DateInput />', () => {
|
|
363
340
|
});
|
364
341
|
it('should call onRequestShowCalendar when input receives up arrow event', async () => {
|
365
342
|
const onRequestShowCalendar = vi.fn();
|
366
|
-
render(
|
343
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
367
344
|
renderLabel: "Choose date",
|
368
345
|
renderWeekdayLabels: weekdayLabels,
|
369
|
-
onRequestShowCalendar: onRequestShowCalendar
|
370
|
-
|
371
|
-
}));
|
346
|
+
onRequestShowCalendar: onRequestShowCalendar
|
347
|
+
}, generateDays()));
|
372
348
|
const dateInput = screen.getByLabelText('Choose date');
|
373
349
|
await userEvent.type(dateInput, '{arrowup}');
|
374
350
|
await waitFor(() => {
|
@@ -377,13 +353,12 @@ describe('<DateInput />', () => {
|
|
377
353
|
});
|
378
354
|
it('should not call onRequestShowCalendar when input receives up arrow event if calendar is already showing', async () => {
|
379
355
|
const onRequestShowCalendar = vi.fn();
|
380
|
-
render(
|
356
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
381
357
|
renderLabel: "Choose date",
|
382
358
|
renderWeekdayLabels: weekdayLabels,
|
383
359
|
onRequestShowCalendar: onRequestShowCalendar,
|
384
|
-
isShowingCalendar: true
|
385
|
-
|
386
|
-
}));
|
360
|
+
isShowingCalendar: true
|
361
|
+
}, generateDays()));
|
387
362
|
const dateInput = screen.getByLabelText('Choose date');
|
388
363
|
await userEvent.type(dateInput, '{arrowup}');
|
389
364
|
await waitFor(() => {
|
@@ -392,12 +367,11 @@ describe('<DateInput />', () => {
|
|
392
367
|
});
|
393
368
|
it('should call onRequestShowCalendar when input receives onChange event', async () => {
|
394
369
|
const onRequestShowCalendar = vi.fn();
|
395
|
-
render(
|
370
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
396
371
|
renderLabel: "Choose date",
|
397
372
|
renderWeekdayLabels: weekdayLabels,
|
398
|
-
onRequestShowCalendar: onRequestShowCalendar
|
399
|
-
|
400
|
-
}));
|
373
|
+
onRequestShowCalendar: onRequestShowCalendar
|
374
|
+
}, generateDays()));
|
401
375
|
const dateInput = screen.getByLabelText('Choose date');
|
402
376
|
fireEvent.change(dateInput, {
|
403
377
|
target: {
|
@@ -410,13 +384,12 @@ describe('<DateInput />', () => {
|
|
410
384
|
});
|
411
385
|
it('should not call onRequestShowCalendar when disabled', async () => {
|
412
386
|
const onRequestShowCalendar = vi.fn();
|
413
|
-
render(
|
387
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
414
388
|
renderLabel: "Choose date",
|
415
389
|
renderWeekdayLabels: weekdayLabels,
|
416
390
|
onRequestShowCalendar: onRequestShowCalendar,
|
417
|
-
interaction: "disabled"
|
418
|
-
|
419
|
-
}));
|
391
|
+
interaction: "disabled"
|
392
|
+
}, generateDays()));
|
420
393
|
const dateInput = screen.getByLabelText('Choose date');
|
421
394
|
fireEvent.click(dateInput);
|
422
395
|
await userEvent.type(dateInput, '{arrowup}{arrowdown}{space}January 5', {
|
@@ -431,14 +404,13 @@ describe('<DateInput />', () => {
|
|
431
404
|
it('should call onRequestHideCalendar and onRequestValidateDate input receives onBlur event', async () => {
|
432
405
|
const onRequestHideCalendar = vi.fn();
|
433
406
|
const onRequestValidateDate = vi.fn();
|
434
|
-
render(
|
407
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
435
408
|
renderLabel: "Choose date",
|
436
409
|
renderWeekdayLabels: weekdayLabels,
|
437
410
|
onRequestHideCalendar: onRequestHideCalendar,
|
438
411
|
onRequestValidateDate: onRequestValidateDate,
|
439
|
-
isShowingCalendar: true
|
440
|
-
|
441
|
-
}));
|
412
|
+
isShowingCalendar: true
|
413
|
+
}, generateDays()));
|
442
414
|
const dateInput = screen.getByLabelText('Choose date');
|
443
415
|
fireEvent.blur(dateInput);
|
444
416
|
await waitFor(() => {
|
@@ -449,14 +421,13 @@ describe('<DateInput />', () => {
|
|
449
421
|
it('should call onRequestHideCalendar and onRequestValidateDate when input receives esc event', async () => {
|
450
422
|
const onRequestHideCalendar = vi.fn();
|
451
423
|
const onRequestValidateDate = vi.fn();
|
452
|
-
render(
|
424
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
453
425
|
renderLabel: "Choose date",
|
454
426
|
renderWeekdayLabels: weekdayLabels,
|
455
427
|
onRequestHideCalendar: onRequestHideCalendar,
|
456
428
|
onRequestValidateDate: onRequestValidateDate,
|
457
|
-
isShowingCalendar: true
|
458
|
-
|
459
|
-
}));
|
429
|
+
isShowingCalendar: true
|
430
|
+
}, generateDays()));
|
460
431
|
const dateInput = screen.getByLabelText('Choose date');
|
461
432
|
await userEvent.type(dateInput, '{esc}');
|
462
433
|
await waitFor(() => {
|
@@ -468,20 +439,19 @@ describe('<DateInput />', () => {
|
|
468
439
|
const onRequestHideCalendar = vi.fn();
|
469
440
|
const onRequestValidateDate = vi.fn();
|
470
441
|
const days = generateDays();
|
471
|
-
days[4] = _Calendar$Day || (_Calendar$Day =
|
442
|
+
days[4] = _Calendar$Day || (_Calendar$Day = /*#__PURE__*/React.createElement(Calendar.Day, {
|
443
|
+
key: "4",
|
472
444
|
label: "4",
|
473
445
|
date: "2019-09-28",
|
474
|
-
isSelected: true
|
475
|
-
|
476
|
-
|
477
|
-
render(_jsx(DateInput, {
|
446
|
+
isSelected: true
|
447
|
+
}, 4));
|
448
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
478
449
|
renderLabel: "Choose date",
|
479
450
|
renderWeekdayLabels: weekdayLabels,
|
480
451
|
onRequestHideCalendar: onRequestHideCalendar,
|
481
452
|
onRequestValidateDate: onRequestValidateDate,
|
482
|
-
isShowingCalendar: true
|
483
|
-
|
484
|
-
}));
|
453
|
+
isShowingCalendar: true
|
454
|
+
}, days));
|
485
455
|
const dateInput = screen.getByLabelText('Choose date');
|
486
456
|
await userEvent.type(dateInput, '{enter}');
|
487
457
|
await waitFor(() => {
|
@@ -492,27 +462,24 @@ describe('<DateInput />', () => {
|
|
492
462
|
});
|
493
463
|
it('should render calendar navigation label', () => {
|
494
464
|
const label = 'January 2019';
|
495
|
-
render(
|
465
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
496
466
|
renderLabel: "Choose date",
|
497
467
|
renderWeekdayLabels: weekdayLabels,
|
498
|
-
renderNavigationLabel:
|
499
|
-
"data-testId": "label-id"
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
children: generateDays()
|
504
|
-
}));
|
468
|
+
renderNavigationLabel: /*#__PURE__*/React.createElement("div", {
|
469
|
+
"data-testId": "label-id"
|
470
|
+
}, label),
|
471
|
+
isShowingCalendar: true
|
472
|
+
}, generateDays()));
|
505
473
|
const navigationLabel = screen.getByTestId('label-id');
|
506
474
|
expect(navigationLabel).toBeInTheDocument();
|
507
475
|
expect(navigationLabel).toHaveTextContent(label);
|
508
476
|
});
|
509
477
|
it('should render calendar weekday labels', async () => {
|
510
|
-
render(
|
478
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
511
479
|
renderLabel: "Choose date",
|
512
480
|
renderWeekdayLabels: weekdayLabels,
|
513
|
-
isShowingCalendar: true
|
514
|
-
|
515
|
-
}));
|
481
|
+
isShowingCalendar: true
|
482
|
+
}, generateDays()));
|
516
483
|
const calendar = await screen.findByRole('listbox');
|
517
484
|
const headers = calendar.querySelectorAll('th');
|
518
485
|
expect(headers.length).toEqual(7);
|
@@ -521,20 +488,17 @@ describe('<DateInput />', () => {
|
|
521
488
|
});
|
522
489
|
});
|
523
490
|
it('should render all focusable elements in calendar with tabIndex="-1"', async () => {
|
524
|
-
render(
|
491
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
525
492
|
renderLabel: "Choose date",
|
526
493
|
renderWeekdayLabels: weekdayLabels,
|
527
|
-
renderNextMonthButton: _button || (_button =
|
528
|
-
"data-testId": "button-next"
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
isShowingCalendar: true,
|
536
|
-
children: generateDays()
|
537
|
-
}));
|
494
|
+
renderNextMonthButton: _button || (_button = /*#__PURE__*/React.createElement("button", {
|
495
|
+
"data-testId": "button-next"
|
496
|
+
}, "next")),
|
497
|
+
renderPrevMonthButton: _button2 || (_button2 = /*#__PURE__*/React.createElement("button", {
|
498
|
+
"data-testId": "button-prev"
|
499
|
+
}, "prev")),
|
500
|
+
isShowingCalendar: true
|
501
|
+
}, generateDays()));
|
538
502
|
const calendar = await screen.findByRole('listbox');
|
539
503
|
const calendarDays = calendar.querySelectorAll('button');
|
540
504
|
const nextMonthButton = screen.getByTestId('button-next');
|
@@ -548,19 +512,18 @@ describe('<DateInput />', () => {
|
|
548
512
|
});
|
549
513
|
it('should render days with the correct role', async () => {
|
550
514
|
const days = generateDays();
|
551
|
-
days[5] = _Calendar$Day2 || (_Calendar$Day2 =
|
515
|
+
days[5] = _Calendar$Day2 || (_Calendar$Day2 = /*#__PURE__*/React.createElement(Calendar.Day, {
|
516
|
+
key: "5",
|
552
517
|
label: "5",
|
553
518
|
date: "2019-09-28",
|
554
519
|
id: "5",
|
555
|
-
isOutsideMonth: true
|
556
|
-
|
557
|
-
|
558
|
-
render(_jsx(DateInput, {
|
520
|
+
isOutsideMonth: true
|
521
|
+
}, "outside"));
|
522
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
559
523
|
renderLabel: "Choose date",
|
560
524
|
renderWeekdayLabels: weekdayLabels,
|
561
|
-
isShowingCalendar: true
|
562
|
-
|
563
|
-
}));
|
525
|
+
isShowingCalendar: true
|
526
|
+
}, days));
|
564
527
|
const calendar = await screen.findByRole('listbox');
|
565
528
|
const calendarDays = calendar.querySelectorAll('button');
|
566
529
|
calendarDays.forEach(day => {
|
@@ -573,19 +536,18 @@ describe('<DateInput />', () => {
|
|
573
536
|
});
|
574
537
|
it('should assign aria-selected to the selected date and link it to the input', async () => {
|
575
538
|
const days = generateDays();
|
576
|
-
days[7] = _Calendar$Day3 || (_Calendar$Day3 =
|
539
|
+
days[7] = _Calendar$Day3 || (_Calendar$Day3 = /*#__PURE__*/React.createElement(Calendar.Day, {
|
540
|
+
key: "7",
|
577
541
|
label: "7",
|
578
542
|
date: "2019-09-28",
|
579
543
|
id: "selected-day-id",
|
580
|
-
isSelected: true
|
581
|
-
|
582
|
-
|
583
|
-
render(_jsx(DateInput, {
|
544
|
+
isSelected: true
|
545
|
+
}, "selected"));
|
546
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
584
547
|
renderLabel: "Choose date",
|
585
548
|
renderWeekdayLabels: weekdayLabels,
|
586
|
-
isShowingCalendar: true
|
587
|
-
|
588
|
-
}));
|
549
|
+
isShowingCalendar: true
|
550
|
+
}, days));
|
589
551
|
const calendar = await screen.findByRole('listbox');
|
590
552
|
const calendarDays = calendar.querySelectorAll('button');
|
591
553
|
let selectedDayID = '';
|
@@ -615,7 +577,7 @@ describe('<DateInput />', () => {
|
|
615
577
|
describe('with minimal config', () => {
|
616
578
|
it('should render 44 buttons (a calendar) when clicked', async () => {
|
617
579
|
const onChange = vi.fn();
|
618
|
-
render(
|
580
|
+
render(/*#__PURE__*/React.createElement(DateInput, {
|
619
581
|
renderLabel: "Choose date",
|
620
582
|
assistiveText: "Type a date or use arrow keys to navigate date picker.",
|
621
583
|
width: "20rem",
|