UNPKG

1.25 kBTypeScriptView Raw
1import React from "react";
2
3import { previousButton } from "@/test/elements";
4import { render, screen } from "@/test/render";
5import { user } from "@/test/user";
6
7import { MultipleMonths } from "./MultipleMonths";
8
9const today = new Date(2023, 11, 3);
10
11beforeAll(() => jest.setSystemTime(today));
12afterAll(() => jest.useRealTimers());
13
14beforeEach(() => {
15 render(<MultipleMonths />);
16});
17
18test("should render 2 grids", () => {
19 expect(screen.getAllByRole("grid")).toHaveLength(2);
20});
21
22test("the first grid should be November", () => {
23 const grids = screen.getAllByRole("grid");
24 expect(grids[0]).toHaveAccessibleName("December 2023");
25});
26
27test("the second grid should be December", () => {
28 const grids = screen.getAllByRole("grid");
29 expect(grids[1]).toHaveAccessibleName("January 2024");
30});
31
32describe("when the previous month button is clicked", () => {
33 beforeEach(() => user.click(previousButton()));
34 test("the first month should be October", () => {
35 const grids = screen.getAllByRole("grid");
36 expect(grids[0]).toHaveAccessibleName("November 2023");
37 });
38 test("the first month should be November", () => {
39 const grids = screen.getAllByRole("grid");
40 expect(grids[1]).toHaveAccessibleName("December 2023");
41 });
42});