UNPKG

1.59 kBTypeScriptView Raw
1import React from "react";
2
3import { dateButton, gridcell } from "@/test/elements";
4import { render } from "@/test/render";
5import { user } from "@/test/user";
6
7import { RangeShiftKey } from "./RangeShiftKey";
8
9const today = new Date(2021, 10, 25);
10
11beforeAll(() => jest.setSystemTime(today));
12afterAll(() => jest.useRealTimers());
13
14beforeEach(() => render(<RangeShiftKey />));
15
16describe("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});