UNPKG

788 BTypeScriptView Raw
1import React from "react";
2
3import { startOfMonth } from "date-fns";
4
5import { dateButton } from "@/test/elements";
6import { render, screen, fireEvent } from "@/test/render";
7
8import { CustomDayButton } from "./CustomDayButton";
9
10const today = new Date(2021, 10, 25);
11beforeAll(() => jest.setSystemTime(today));
12afterAll(() => jest.useRealTimers());
13
14beforeEach(() => {
15 render(<CustomDayButton />);
16});
17
18test("update the footer when a day is double clicked", () => {
19 fireEvent.doubleClick(dateButton(today));
20 expect(screen.getByText(today.toDateString())).toBeInTheDocument();
21});
22
23test("update the footer when a day is single clicked", () => {
24 fireEvent.click(dateButton(startOfMonth(today)));
25 expect(screen.getByText("Double click to select a date")).toBeInTheDocument();
26});