@khanacademy/wonder-blocks-birthday-picker 1.2.6 → 1.2.7
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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-birthday-picker",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@babel/runtime": "^7.16.3",
|
|
17
17
|
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
18
18
|
"@khanacademy/wonder-blocks-core": "^4.3.1",
|
|
19
|
-
"@khanacademy/wonder-blocks-dropdown": "^2.7.
|
|
19
|
+
"@khanacademy/wonder-blocks-dropdown": "^2.7.1",
|
|
20
20
|
"@khanacademy/wonder-blocks-icon": "^1.2.27",
|
|
21
21
|
"@khanacademy/wonder-blocks-layout": "^1.4.9",
|
|
22
22
|
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import moment from "moment";
|
|
4
4
|
import {render, screen} from "@testing-library/react";
|
|
5
5
|
import * as DateMock from "jest-date-mock";
|
|
6
|
-
import userEvent from "
|
|
6
|
+
import userEvent from "@testing-library/user-event";
|
|
7
7
|
|
|
8
8
|
import BirthdayPicker, {defaultLabels} from "../birthday-picker.js";
|
|
9
9
|
|
|
@@ -14,7 +14,6 @@ describe("BirthdayPicker", () => {
|
|
|
14
14
|
|
|
15
15
|
describe("render", () => {
|
|
16
16
|
beforeEach(() => {
|
|
17
|
-
jest.useRealTimers();
|
|
18
17
|
DateMock.advanceTo(today);
|
|
19
18
|
});
|
|
20
19
|
|
|
@@ -72,7 +71,6 @@ describe("BirthdayPicker", () => {
|
|
|
72
71
|
|
|
73
72
|
it("renders with a invalid default future value", () => {
|
|
74
73
|
// Arrange
|
|
75
|
-
jest.useRealTimers();
|
|
76
74
|
DateMock.advanceTo(today);
|
|
77
75
|
const date = moment(today).add(1, "day");
|
|
78
76
|
const defaultValue = date.format("YYYY-MM-DD");
|
|
@@ -95,7 +93,7 @@ describe("BirthdayPicker", () => {
|
|
|
95
93
|
expect(yearPicker).toHaveTextContent("2021");
|
|
96
94
|
});
|
|
97
95
|
|
|
98
|
-
it("renders an error with a invalid default future value",
|
|
96
|
+
it("renders an error with a invalid default future value", () => {
|
|
99
97
|
// Arrange
|
|
100
98
|
const date = moment(today).add(1, "day");
|
|
101
99
|
const defaultValue = date.format("YYYY-MM-DD");
|
|
@@ -150,7 +148,7 @@ describe("BirthdayPicker", () => {
|
|
|
150
148
|
expect(yearPicker).toBeDisabled();
|
|
151
149
|
});
|
|
152
150
|
|
|
153
|
-
it("renders an error with an invalid default value",
|
|
151
|
+
it("renders an error with an invalid default value", () => {
|
|
154
152
|
// Arrange
|
|
155
153
|
const defaultValue = "2021-02-31";
|
|
156
154
|
|
|
@@ -168,16 +166,7 @@ describe("BirthdayPicker", () => {
|
|
|
168
166
|
});
|
|
169
167
|
|
|
170
168
|
describe("onChange", () => {
|
|
171
|
-
|
|
172
|
-
jest.useFakeTimers();
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
afterEach(() => {
|
|
176
|
-
jest.runOnlyPendingTimers();
|
|
177
|
-
jest.useRealTimers();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("onChange triggers when a new value is selected", async () => {
|
|
169
|
+
it("onChange triggers when a new value is selected", () => {
|
|
181
170
|
// Arrange
|
|
182
171
|
const onChange = jest.fn();
|
|
183
172
|
|
|
@@ -185,7 +174,7 @@ describe("BirthdayPicker", () => {
|
|
|
185
174
|
|
|
186
175
|
// Act
|
|
187
176
|
userEvent.click(screen.getByTestId("birthday-picker-month"));
|
|
188
|
-
const monthOption =
|
|
177
|
+
const monthOption = screen.getByRole("option", {
|
|
189
178
|
name: "Jul",
|
|
190
179
|
});
|
|
191
180
|
userEvent.click(monthOption, undefined, {
|
|
@@ -193,13 +182,13 @@ describe("BirthdayPicker", () => {
|
|
|
193
182
|
});
|
|
194
183
|
|
|
195
184
|
userEvent.click(screen.getByTestId("birthday-picker-day"));
|
|
196
|
-
const dayOption =
|
|
185
|
+
const dayOption = screen.getByRole("option", {name: "5"});
|
|
197
186
|
userEvent.click(dayOption, undefined, {
|
|
198
187
|
skipPointerEventsCheck: true,
|
|
199
188
|
});
|
|
200
189
|
|
|
201
190
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
202
|
-
const yearOption =
|
|
191
|
+
const yearOption = screen.getByRole("option", {
|
|
203
192
|
name: "2021",
|
|
204
193
|
});
|
|
205
194
|
userEvent.click(yearOption, undefined, {
|
|
@@ -210,13 +199,13 @@ describe("BirthdayPicker", () => {
|
|
|
210
199
|
expect(onChange).toHaveBeenCalledWith("2021-07-05");
|
|
211
200
|
});
|
|
212
201
|
|
|
213
|
-
it("onChange triggers multiple times when a new value is selected",
|
|
202
|
+
it("onChange triggers multiple times when a new value is selected", () => {
|
|
214
203
|
// Arrange
|
|
215
204
|
const onChange = jest.fn();
|
|
216
205
|
render(<BirthdayPicker onChange={onChange} />);
|
|
217
206
|
// Pick one date
|
|
218
207
|
userEvent.click(screen.getByTestId("birthday-picker-month"));
|
|
219
|
-
const monthOption =
|
|
208
|
+
const monthOption = screen.getByRole("option", {
|
|
220
209
|
name: "Jul",
|
|
221
210
|
});
|
|
222
211
|
userEvent.click(monthOption, undefined, {
|
|
@@ -224,14 +213,14 @@ describe("BirthdayPicker", () => {
|
|
|
224
213
|
});
|
|
225
214
|
|
|
226
215
|
userEvent.click(screen.getByTestId("birthday-picker-day"));
|
|
227
|
-
const dayOption =
|
|
216
|
+
const dayOption = screen.getByRole("option", {name: "5"});
|
|
228
217
|
|
|
229
218
|
userEvent.click(dayOption, undefined, {
|
|
230
219
|
skipPointerEventsCheck: true,
|
|
231
220
|
});
|
|
232
221
|
|
|
233
222
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
234
|
-
const yearOption =
|
|
223
|
+
const yearOption = screen.getByRole("option", {
|
|
235
224
|
name: "2021",
|
|
236
225
|
});
|
|
237
226
|
userEvent.click(yearOption, undefined, {
|
|
@@ -241,7 +230,7 @@ describe("BirthdayPicker", () => {
|
|
|
241
230
|
// Act
|
|
242
231
|
// Pick Another Date
|
|
243
232
|
userEvent.click(screen.getByTestId("birthday-picker-month"));
|
|
244
|
-
const monthOptionNew =
|
|
233
|
+
const monthOptionNew = screen.getByRole("option", {
|
|
245
234
|
name: "Aug",
|
|
246
235
|
});
|
|
247
236
|
userEvent.click(monthOptionNew, undefined, {
|
|
@@ -249,13 +238,13 @@ describe("BirthdayPicker", () => {
|
|
|
249
238
|
});
|
|
250
239
|
|
|
251
240
|
userEvent.click(screen.getByTestId("birthday-picker-day"));
|
|
252
|
-
const dayOptionNew =
|
|
241
|
+
const dayOptionNew = screen.getByRole("option", {name: "9"});
|
|
253
242
|
userEvent.click(dayOptionNew, undefined, {
|
|
254
243
|
skipPointerEventsCheck: true,
|
|
255
244
|
});
|
|
256
245
|
|
|
257
246
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
258
|
-
const yearOptionNew =
|
|
247
|
+
const yearOptionNew = screen.getByRole("option", {
|
|
259
248
|
name: "2020",
|
|
260
249
|
});
|
|
261
250
|
userEvent.click(yearOptionNew, undefined, {
|
|
@@ -266,7 +255,7 @@ describe("BirthdayPicker", () => {
|
|
|
266
255
|
expect(onChange).toHaveBeenLastCalledWith("2020-08-09");
|
|
267
256
|
});
|
|
268
257
|
|
|
269
|
-
it("onChange triggers when a new value is selected after a default value is set",
|
|
258
|
+
it("onChange triggers when a new value is selected after a default value is set", () => {
|
|
270
259
|
// Arrange
|
|
271
260
|
const onChange = jest.fn();
|
|
272
261
|
|
|
@@ -279,7 +268,7 @@ describe("BirthdayPicker", () => {
|
|
|
279
268
|
|
|
280
269
|
// Act
|
|
281
270
|
userEvent.click(screen.getByTestId("birthday-picker-month"));
|
|
282
|
-
const monthOption =
|
|
271
|
+
const monthOption = screen.getByRole("option", {
|
|
283
272
|
name: "Aug",
|
|
284
273
|
});
|
|
285
274
|
userEvent.click(monthOption, undefined, {
|
|
@@ -287,14 +276,14 @@ describe("BirthdayPicker", () => {
|
|
|
287
276
|
});
|
|
288
277
|
|
|
289
278
|
userEvent.click(screen.getByTestId("birthday-picker-day"));
|
|
290
|
-
const dayOption =
|
|
279
|
+
const dayOption = screen.getByRole("option", {name: "9"});
|
|
291
280
|
|
|
292
281
|
userEvent.click(dayOption, undefined, {
|
|
293
282
|
skipPointerEventsCheck: true,
|
|
294
283
|
});
|
|
295
284
|
|
|
296
285
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
297
|
-
const yearOption =
|
|
286
|
+
const yearOption = screen.getByRole("option", {
|
|
298
287
|
name: "2018",
|
|
299
288
|
});
|
|
300
289
|
userEvent.click(yearOption, undefined, {
|
|
@@ -335,7 +324,7 @@ describe("BirthdayPicker", () => {
|
|
|
335
324
|
expect(onChange).toHaveBeenCalledWith(null);
|
|
336
325
|
});
|
|
337
326
|
|
|
338
|
-
it("onChange triggers only one null when multiple invalid values are selected after a default value is set",
|
|
327
|
+
it("onChange triggers only one null when multiple invalid values are selected after a default value is set", () => {
|
|
339
328
|
// Arrange
|
|
340
329
|
const onChange = jest.fn();
|
|
341
330
|
|
|
@@ -348,7 +337,7 @@ describe("BirthdayPicker", () => {
|
|
|
348
337
|
|
|
349
338
|
// Act
|
|
350
339
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
351
|
-
const yearOption =
|
|
340
|
+
const yearOption = screen.getByRole("option", {
|
|
352
341
|
name: "2020",
|
|
353
342
|
});
|
|
354
343
|
userEvent.click(yearOption, undefined, {
|
|
@@ -359,7 +348,7 @@ describe("BirthdayPicker", () => {
|
|
|
359
348
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
360
349
|
});
|
|
361
350
|
|
|
362
|
-
it("onChange triggers the first day of the month when monthYearOnly is set",
|
|
351
|
+
it("onChange triggers the first day of the month when monthYearOnly is set", () => {
|
|
363
352
|
// Arrange
|
|
364
353
|
const onChange = jest.fn();
|
|
365
354
|
|
|
@@ -367,7 +356,7 @@ describe("BirthdayPicker", () => {
|
|
|
367
356
|
|
|
368
357
|
// Act
|
|
369
358
|
userEvent.click(screen.getByTestId("birthday-picker-month"));
|
|
370
|
-
const monthOption =
|
|
359
|
+
const monthOption = screen.getByRole("option", {
|
|
371
360
|
name: "Aug",
|
|
372
361
|
});
|
|
373
362
|
userEvent.click(monthOption, undefined, {
|
|
@@ -375,7 +364,7 @@ describe("BirthdayPicker", () => {
|
|
|
375
364
|
});
|
|
376
365
|
|
|
377
366
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
378
|
-
const yearOption =
|
|
367
|
+
const yearOption = screen.getByRole("option", {
|
|
379
368
|
name: "2018",
|
|
380
369
|
});
|
|
381
370
|
userEvent.click(yearOption, undefined, {
|
|
@@ -387,7 +376,7 @@ describe("BirthdayPicker", () => {
|
|
|
387
376
|
expect(onChange).toHaveBeenCalledWith("2018-08-01");
|
|
388
377
|
});
|
|
389
378
|
|
|
390
|
-
it("onChange triggers the passed-in day intact when defaultValue and monthYearOnly are set",
|
|
379
|
+
it("onChange triggers the passed-in day intact when defaultValue and monthYearOnly are set", () => {
|
|
391
380
|
// Arrange
|
|
392
381
|
const onChange = jest.fn();
|
|
393
382
|
|
|
@@ -401,7 +390,7 @@ describe("BirthdayPicker", () => {
|
|
|
401
390
|
|
|
402
391
|
// Act
|
|
403
392
|
userEvent.click(screen.getByTestId("birthday-picker-month"));
|
|
404
|
-
const monthOption =
|
|
393
|
+
const monthOption = screen.getByRole("option", {
|
|
405
394
|
name: "Aug",
|
|
406
395
|
});
|
|
407
396
|
userEvent.click(monthOption, undefined, {
|
|
@@ -409,7 +398,7 @@ describe("BirthdayPicker", () => {
|
|
|
409
398
|
});
|
|
410
399
|
|
|
411
400
|
userEvent.click(screen.getByTestId("birthday-picker-year"));
|
|
412
|
-
const yearOption =
|
|
401
|
+
const yearOption = screen.getByRole("option", {
|
|
413
402
|
name: "2018",
|
|
414
403
|
});
|
|
415
404
|
userEvent.click(yearOption, undefined, {
|
|
@@ -431,7 +420,6 @@ describe("BirthdayPicker", () => {
|
|
|
431
420
|
};
|
|
432
421
|
|
|
433
422
|
beforeEach(() => {
|
|
434
|
-
jest.useRealTimers();
|
|
435
423
|
DateMock.advanceTo(today);
|
|
436
424
|
});
|
|
437
425
|
|
|
@@ -488,7 +476,7 @@ describe("BirthdayPicker", () => {
|
|
|
488
476
|
expect(screen.getByText("Day")).toBeInTheDocument(); // EN
|
|
489
477
|
});
|
|
490
478
|
|
|
491
|
-
it("renders a translated error with an invalid default value",
|
|
479
|
+
it("renders a translated error with an invalid default value", () => {
|
|
492
480
|
// Arrange
|
|
493
481
|
const defaultValue = "2021-02-31"; // There is no Feb 31st
|
|
494
482
|
|