1 | import React from "react";
|
2 |
|
3 | import { activeElement, dateButton } from "@/test/elements";
|
4 | import { render } from "@/test/render";
|
5 | import { user } from "@/test/user";
|
6 |
|
7 | import { FocusRecursive } from "./FocusRecursive";
|
8 |
|
9 | const today = new Date(2022, 5, 10);
|
10 |
|
11 | beforeAll(() => jest.setSystemTime(today));
|
12 | afterAll(() => jest.useRealTimers());
|
13 |
|
14 | test("the first selected day should have focus", async () => {
|
15 | render(<FocusRecursive />).container;
|
16 | await user.tab();
|
17 | await user.tab();
|
18 | await user.tab();
|
19 | await user.type(activeElement(), "{arrowdown}");
|
20 | await user.type(activeElement(), "{arrowdown}");
|
21 | await user.type(activeElement(), "{arrowdown}");
|
22 | await user.type(activeElement(), "{arrowdown}");
|
23 | expect(dateButton(new Date(2022, 5, 22))).toHaveFocus();
|
24 | });
|