1 | import React from "react";
|
2 |
|
3 | import { previousButton } from "@/test/elements";
|
4 | import { render, screen } from "@/test/render";
|
5 | import { user } from "@/test/user";
|
6 |
|
7 | import { MultipleMonths } from "./MultipleMonths";
|
8 |
|
9 | const today = new Date(2023, 11, 3);
|
10 |
|
11 | beforeAll(() => jest.setSystemTime(today));
|
12 | afterAll(() => jest.useRealTimers());
|
13 |
|
14 | beforeEach(() => {
|
15 | render(<MultipleMonths />);
|
16 | });
|
17 |
|
18 | test("should render 2 grids", () => {
|
19 | expect(screen.getAllByRole("grid")).toHaveLength(2);
|
20 | });
|
21 |
|
22 | test("the first grid should be November", () => {
|
23 | const grids = screen.getAllByRole("grid");
|
24 | expect(grids[0]).toHaveAccessibleName("December 2023");
|
25 | });
|
26 |
|
27 | test("the second grid should be December", () => {
|
28 | const grids = screen.getAllByRole("grid");
|
29 | expect(grids[1]).toHaveAccessibleName("January 2024");
|
30 | });
|
31 |
|
32 | describe("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 | });
|