1 | import React from "react";
|
2 |
|
3 | import { app, grid } from "@/test/elements";
|
4 | import { render, screen } from "@/test/render";
|
5 | import { user } from "@/test/user";
|
6 |
|
7 | import { Disabled } from "./Disabled";
|
8 |
|
9 | const today = new Date(2022, 5, 10);
|
10 |
|
11 | beforeAll(() => jest.setSystemTime(today));
|
12 | afterAll(() => jest.useRealTimers());
|
13 |
|
14 | beforeEach(() => {
|
15 | render(
|
16 | <div role="application">
|
17 | <Disabled />
|
18 | </div>
|
19 | );
|
20 |
|
21 | });
|
22 |
|
23 | test("should not display the previous button", () => {
|
24 | expect(
|
25 | screen.queryByRole("button", { name: "Previous month" })
|
26 | ).not.toBeInTheDocument();
|
27 | });
|
28 |
|
29 | describe("when the first day is focused", () => {
|
30 | describe("when the Arrow Left is pressed", () => {
|
31 | beforeEach(async () => {
|
32 | await user.type(app(), "{arrowleft}");
|
33 | });
|
34 | test("should still display the same month", () => {
|
35 | expect(grid("June 2022")).toBeInTheDocument();
|
36 | });
|
37 | });
|
38 | });
|
39 | describe("when the last day is focused", () => {
|
40 | describe("when the Arrow Right is pressed", () => {
|
41 | beforeEach(async () => {
|
42 | await user.type(app(), "{arrowleft}");
|
43 | });
|
44 | test("should still display the same month", () => {
|
45 | expect(grid("June 2022")).toBeInTheDocument();
|
46 | });
|
47 | });
|
48 | });
|