UNPKG

1.17 kBTypeScriptView Raw
1import React from "react";
2
3import { dateButton, gridcell } from "@/test/elements";
4import { render, screen } from "@/test/render";
5import { user } from "@/test/user";
6
7import { CustomSingle } from "./CustomSingle";
8
9const today = new Date();
10
11beforeEach(() => {
12 render(<CustomSingle />);
13});
14
15describe("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});