1 | import React from "react";
|
2 |
|
3 | import { dateButton, gridcell } from "@/test/elements";
|
4 | import { render, screen } from "@/test/render";
|
5 | import { user } from "@/test/user";
|
6 |
|
7 | import { CustomSingle } from "./CustomSingle";
|
8 |
|
9 | const today = new Date();
|
10 |
|
11 | beforeEach(() => {
|
12 | render(<CustomSingle />);
|
13 | });
|
14 |
|
15 | describe("when a day is clicked", () => {
|
16 | beforeEach(async () => {
|
17 | await user.click(dateButton(today));
|
18 | });
|
19 | test("the gridcell should appear as selected", () => {
|
20 | expect(gridcell(today, true)).toHaveAttribute("aria-selected", "true");
|
21 | });
|
22 | test("should update the footer", () => {
|
23 | expect(
|
24 | screen.getByText("You selected " + today.toDateString())
|
25 | ).toBeInTheDocument();
|
26 | });
|
27 | describe("when clicking the day again", () => {
|
28 | beforeEach(async () => {
|
29 | await user.click(dateButton(today));
|
30 | });
|
31 | test("should not appear as selected", () => {
|
32 | expect(gridcell(today, true)).not.toHaveAttribute(
|
33 | "aria-selected",
|
34 | "true"
|
35 | );
|
36 | });
|
37 | test("should update the footer", () => {
|
38 | expect(
|
39 | screen.queryByText("You selected Thu Nov 25 2021")
|
40 | ).not.toBeInTheDocument();
|
41 | });
|
42 | });
|
43 | });
|