UNPKG

1.26 kBTypeScriptView Raw
1import React from "react";
2
3import { app, grid } from "@/test/elements";
4import { render, screen } from "@/test/render";
5import { user } from "@/test/user";
6
7import { Disabled } from "./Disabled";
8
9const today = new Date(2022, 5, 10);
10
11beforeAll(() => jest.setSystemTime(today));
12afterAll(() => jest.useRealTimers());
13
14beforeEach(() => {
15 render(
16 <div role="application">
17 <Disabled />
18 </div>
19 );
20 // return act(() => dateButton(firstOfMonth).focus());
21});
22
23test("should not display the previous button", () => {
24 expect(
25 screen.queryByRole("button", { name: "Previous month" })
26 ).not.toBeInTheDocument();
27});
28
29describe("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});
39describe("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});