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