UNPKG

1.35 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 { MultipleMonthsPaged } from "./MultipleMonthsPaged";
8
9const today = new Date(2021, 10, 25);
10
11beforeAll(() => jest.setSystemTime(today));
12afterAll(() => jest.useRealTimers());
13
14beforeEach(() => {
15 render(<MultipleMonthsPaged />);
16});
17
18describe("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 // Test pagination
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});