1 | import React from "react";
|
2 |
|
3 | import {
|
4 | nextButton,
|
5 | dateButton,
|
6 | previousButton,
|
7 | gridcell
|
8 | } from "@/test/elements";
|
9 | import { render } from "@/test/render";
|
10 | import { user } from "@/test/user";
|
11 |
|
12 | import { Start } from "./Start";
|
13 |
|
14 | const today = new Date(2021, 10, 25);
|
15 |
|
16 | beforeAll(() => jest.setSystemTime(today));
|
17 | afterAll(() => jest.useRealTimers());
|
18 |
|
19 | beforeEach(async () => {
|
20 | render(<Start />);
|
21 | });
|
22 |
|
23 | test("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 |
|
29 | test("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 |
|
35 | const day = new Date(2021, 10, 1);
|
36 |
|
37 | describe("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 | });
|