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 { CustomMultiple } from "./CustomMultiple";
|
8 |
|
9 | const today = new Date(2021, 10, 25);
|
10 |
|
11 | beforeAll(() => jest.setSystemTime(today));
|
12 | afterAll(() => jest.useRealTimers());
|
13 |
|
14 | beforeEach(() => {
|
15 | render(<CustomMultiple />);
|
16 | });
|
17 |
|
18 | describe("when a day is clicked", () => {
|
19 | const day1 = new Date(2021, 10, 1);
|
20 | beforeEach(async () => {
|
21 | await user.click(dateButton(day1));
|
22 | });
|
23 | test("should appear as selected", () => {
|
24 | expect(gridcell(day1, true)).toHaveAttribute("aria-selected", "true");
|
25 | });
|
26 | test("should update the footer", () => {
|
27 | expect(screen.getByText("You selected 1 days.")).toBeInTheDocument();
|
28 | });
|
29 | describe("when a second day is clicked", () => {
|
30 | const day2 = new Date(2021, 10, 2);
|
31 | beforeEach(async () => {
|
32 | await user.click(dateButton(day2));
|
33 | });
|
34 | test("the first day should appear as selected", () => {
|
35 | expect(gridcell(day1, true)).toHaveAttribute("aria-selected", "true");
|
36 | });
|
37 | test("the second day should appear as selected", () => {
|
38 | expect(gridcell(day2, true)).toHaveAttribute("aria-selected", "true");
|
39 | });
|
40 | test("should update the footer", () => {
|
41 | expect(screen.getByText("You selected 2 days.")).toBeInTheDocument();
|
42 | });
|
43 | });
|
44 | });
|