Skip to content

Commit

Permalink
fix src/test/month_dropdown_test.test.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki0410-dev committed Jun 8, 2024
1 parent 96a104a commit 894fe39
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const babelTargetList = [
"calendar_test\\.test\\.tsx",
"datepicker_test\\.test\\.tsx",
"min_time_test\\.test\\.tsx",
"month_dropdown_test\\.test\\.tsx",
"month_test\\.test\\.tsx",
"multi_month_test\\.test\\.tsx",
"multiple_selected_dates\\.test\\.tsx",
Expand All @@ -28,7 +27,7 @@ const tsTargetList = [
"index\\.ts",
"inject_times_test\\.test\\.tsx",
// "min_time_test\\.test\\.tsx",
// "month_dropdown_test\\.test\\.tsx",
"month_dropdown_test\\.test\\.tsx",
// "month_test\\.test\\.tsx",
"month_year_dropdown_test\\.test\\.tsx",
// "multi_month_test\\.test\\.tsx",
Expand Down
22 changes: 15 additions & 7 deletions src/test/month_dropdown_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ import { render, fireEvent } from "@testing-library/react";
import { el } from "date-fns/locale/el";
import { ru } from "date-fns/locale/ru";
import { zhCN } from "date-fns/locale/zh-CN";
import range from "lodash/range";
import React from "react";
import onClickOutside from "react-onclickoutside";

import { getMonthInLocale, registerLocale } from "../date_utils";
import MonthDropdown from "../month_dropdown";
import MonthDropdownOptions from "../month_dropdown_options";

import { range } from "./test_utils";

type MonthDropdownProps = React.ComponentProps<typeof MonthDropdown>;

describe("MonthDropdown", () => {
let monthDropdown: HTMLElement | null = null;
let handleChangeResult;
const mockHandleChange = function (changeInput) {
let handleChangeResult: number | null;
const mockHandleChange = function (changeInput: number) {
handleChangeResult = changeInput;
};

function getMonthDropdown(overrideProps?) {
function getMonthDropdown(
overrideProps?: Partial<
Pick<MonthDropdownProps, "dropdownMode" | "month" | "onChange">
> &
Omit<MonthDropdownProps, "dropdownMode" | "month" | "onChange">,
) {
return render(
<MonthDropdown
dropdownMode="scroll"
Expand Down Expand Up @@ -105,7 +113,7 @@ describe("MonthDropdown", () => {
);
fireEvent.click(
(monthDropdown?.querySelectorAll(".react-datepicker__month-option") ??
[])[1],
[])[1] ?? new HTMLElement(),
);
expect(
monthDropdown?.querySelectorAll(".react-datepicker__month-dropdown"),
Expand Down Expand Up @@ -137,7 +145,7 @@ describe("MonthDropdown", () => {
);
fireEvent.click(
(monthDropdown?.querySelectorAll(".react-datepicker__month-option") ??
[])[11],
[])[11] ?? new HTMLElement(),
);
expect(handleChangeResult).toBeNull();
});
Expand All @@ -149,7 +157,7 @@ describe("MonthDropdown", () => {
);
fireEvent.click(
(monthDropdown?.querySelectorAll(".react-datepicker__month-option") ??
[])[2],
[])[2] ?? new HTMLElement(),
);
expect(handleChangeResult).toEqual(2);
});
Expand Down

0 comments on commit 894fe39

Please sign in to comment.