UNPKG

747 BTypeScriptView Raw
1import React from "react";
2
3import { grid } from "@/test/elements";
4import { render, screen } from "@/test/render";
5import { user } from "@/test/user";
6
7import { Controlled } from "./Controlled";
8
9beforeAll(() => jest.setSystemTime(new Date(2022, 5, 10)));
10afterAll(() => jest.useRealTimers());
11
12describe('when the "Today" button is clicked', () => {
13 const todayButton = () => screen.getByRole("button", { name: "Go to Today" });
14 beforeEach(async () => {
15 render(<Controlled />);
16 await user.click(todayButton());
17 });
18 test("the button should be disabled", async () => {
19 expect(todayButton()).toBeDisabled();
20 });
21 test("should display the current month", () => {
22 expect(grid()).toHaveAccessibleName("June 2022");
23 });
24});