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 { MultipleMonthsPaged } from "./MultipleMonthsPaged";
|
8 |
|
9 | const today = new Date(2021, 10, 25);
|
10 |
|
11 | beforeAll(() => jest.setSystemTime(today));
|
12 | afterAll(() => jest.useRealTimers());
|
13 |
|
14 | beforeEach(() => {
|
15 | render(<MultipleMonthsPaged />);
|
16 | });
|
17 |
|
18 | describe("when rendering November 2021", () => {
|
19 | test("should render 2 grids", () => {
|
20 | expect(screen.getAllByRole("grid")).toHaveLength(2);
|
21 | });
|
22 | test("the first grid should be November", () => {
|
23 | const grids = screen.getAllByRole("grid");
|
24 | expect(grids[0]).toHaveAccessibleName("November 2021");
|
25 | });
|
26 | test("the second grid should be December", () => {
|
27 | expect(screen.getAllByRole("grid")[1]).toHaveAccessibleName(
|
28 | "December 2021"
|
29 | );
|
30 | });
|
31 |
|
32 | describe("when the previous month button is clicked", () => {
|
33 | beforeEach(async () => user.click(previousButton()));
|
34 | test("the first month should be September", () => {
|
35 | expect(screen.getAllByRole("grid")[0]).toHaveAccessibleName(
|
36 | "September 2021"
|
37 | );
|
38 | });
|
39 | test("the last month should be October", () => {
|
40 | expect(screen.getAllByRole("grid")[1]).toHaveAccessibleName(
|
41 | "October 2021"
|
42 | );
|
43 | });
|
44 | });
|
45 | });
|