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