UNPKG

1.32 kBTypeScriptView Raw
1import React from "react";
2
3import { labelMonthDropdown } from "react-day-picker";
4
5import { grid } from "@/test/elements";
6import { screen, render } from "@/test/render";
7import { user } from "@/test/user";
8
9import { DropdownMultipleMonths } from "./DropdownMultipleMonths";
10
11const today = new Date(2023, 9, 16);
12
13beforeAll(() => jest.setSystemTime(today));
14afterAll(() => jest.useRealTimers());
15
16beforeEach(() => {
17 render(<DropdownMultipleMonths />);
18});
19
20describe("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
33describe("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});