1 | import React from "react";
|
2 |
|
3 | import { labelMonthDropdown } from "react-day-picker";
|
4 |
|
5 | import { grid } from "@/test/elements";
|
6 | import { screen, render } from "@/test/render";
|
7 | import { user } from "@/test/user";
|
8 |
|
9 | import { DropdownMultipleMonths } from "./DropdownMultipleMonths";
|
10 |
|
11 | const today = new Date(2023, 9, 16);
|
12 |
|
13 | beforeAll(() => jest.setSystemTime(today));
|
14 | afterAll(() => jest.useRealTimers());
|
15 |
|
16 | beforeEach(() => {
|
17 | render(<DropdownMultipleMonths />);
|
18 | });
|
19 |
|
20 | describe("when choosing a month from the first dropdown", () => {
|
21 | const monthName = "January";
|
22 | beforeEach(async () => {
|
23 | const firstDropDown = screen.getAllByRole("combobox", {
|
24 | name: labelMonthDropdown()
|
25 | })[0];
|
26 | await user.selectOptions(firstDropDown, monthName);
|
27 | });
|
28 | test("should display the month in the first dropdown", () => {
|
29 | expect(grid(`${monthName} 2023`)).toBeInTheDocument();
|
30 | });
|
31 | });
|
32 |
|
33 | describe("when choosing a month from the third dropdown", () => {
|
34 | const newMonthName = "October";
|
35 | beforeEach(async () => {
|
36 | const thirdDropDown = screen.getAllByRole("combobox", {
|
37 | name: labelMonthDropdown()
|
38 | })[2];
|
39 | await user.selectOptions(thirdDropDown, newMonthName);
|
40 | });
|
41 | test("should display the month selected the third dropdown", () => {
|
42 | expect(grid(`${newMonthName} 2023`)).toBeInTheDocument();
|
43 | });
|
44 | });
|