1 | import React from "react";
|
2 |
|
3 | import { dateButton, gridcell } from "@/test/elements";
|
4 | import { render } from "@/test/render";
|
5 | import { user } from "@/test/user";
|
6 |
|
7 | import { RangeShiftKey } from "./RangeShiftKey";
|
8 |
|
9 | const today = new Date(2021, 10, 25);
|
10 |
|
11 | beforeAll(() => jest.setSystemTime(today));
|
12 | afterAll(() => jest.useRealTimers());
|
13 |
|
14 | beforeEach(() => render(<RangeShiftKey />));
|
15 |
|
16 | describe("when displaying November 2021", () => {
|
17 | describe("when clicking on the 11th", () => {
|
18 | const day1 = new Date(2021, 10, 11);
|
19 | beforeEach(async () => user.click(dateButton(day1)));
|
20 | test("the 11th day should have aria-selected true", () => {
|
21 | expect(gridcell(day1, true)).toHaveAttribute("aria-selected", "true");
|
22 | });
|
23 | describe("when clicking on the 13th", () => {
|
24 | const day2 = new Date(2021, 10, 13);
|
25 | beforeEach(async () => user.click(dateButton(day2)));
|
26 |
|
27 | test("the 11th day should still have aria-selected true", () => {
|
28 | expect(gridcell(day1, true)).toHaveAttribute("aria-selected", "true");
|
29 | });
|
30 | test("the 13th day not should not have aria-selected", () => {
|
31 | expect(gridcell(day2, true)).not.toHaveAttribute("aria-selected");
|
32 | });
|
33 | });
|
34 | describe("when pressing the Shift key", () => {
|
35 | const day2 = new Date(2021, 10, 13);
|
36 | beforeEach(async () => {
|
37 | user.keyboard("{Shift>}");
|
38 | await user.click(dateButton(day2));
|
39 | });
|
40 | test("the 13th day should have aria-selected true", () => {
|
41 | expect(gridcell(day2, true)).toHaveAttribute("aria-selected", "true");
|
42 | });
|
43 | });
|
44 | });
|
45 | });
|