UNPKG

1.12 kBTypeScriptView Raw
1import React from "react";
2
3import {
4 nextButton,
5 dateButton,
6 previousButton,
7 gridcell
8} from "@/test/elements";
9import { render } from "@/test/render";
10import { user } from "@/test/user";
11
12import { Start } from "./Start";
13
14const today = new Date(2021, 10, 25);
15
16beforeAll(() => jest.setSystemTime(today));
17afterAll(() => jest.useRealTimers());
18
19beforeEach(async () => {
20 render(<Start />);
21});
22
23test("should display the next month button", async () => {
24 expect(nextButton()).toBeVisible();
25 expect(nextButton()).not.toHaveAttribute("disabled");
26 expect(nextButton()).not.toHaveAttribute("disabled", "true");
27});
28
29test("should display the previous month buttons", async () => {
30 expect(previousButton()).toBeVisible();
31 expect(previousButton()).not.toHaveAttribute("disabled");
32 expect(previousButton()).not.toHaveAttribute("disabled", "true");
33});
34
35const day = new Date(2021, 10, 1);
36
37describe("when a day is clicked", () => {
38 test("should appear as selected", async () => {
39 await user.click(dateButton(day));
40 expect(gridcell(day, true)).toHaveAttribute("aria-selected", "true");
41 });
42});