* init * updated typing, english localization text, used existing calculatePeriodLimits and isTimeViolatingFutureLimit to determine if go to next month button should be disabled * improving copy * semantic dialog heading tag, proper EN localization, * reverting * force local to origin * Translations by LLM * intit tests * moving NoAvailability to its own file. * refactor overlay component to encpsulate logic in hooks * improved tests * remove unintended change * fix: period data type import. Providing default periodData values * fix: type errors on event object * fix: updates case in type import * removing translations * remove unnecessary import * remove unnecessary import * improving mocks for booker and logger * moving tests to __tests__ folder --------- Co-authored-by: Tushar Bhatt <95581504+TusharBhatt1@users.noreply.github.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import { render } from "@testing-library/react";
|
|
|
|
import dayjs from "@calcom/dayjs";
|
|
import { PeriodType } from "@calcom/prisma/enums";
|
|
|
|
import { DatePicker } from "../DatePicker";
|
|
|
|
const noop = () => {
|
|
/* noop */
|
|
};
|
|
|
|
describe("Tests for DatePicker Component", () => {
|
|
test("Should render correctly with default date", async () => {
|
|
const testDate = dayjs("2024-02-20");
|
|
const { getByTestId } = render(
|
|
<DatePicker
|
|
onChange={noop}
|
|
browsingDate={testDate}
|
|
locale="en"
|
|
periodData={{
|
|
periodType: PeriodType.UNLIMITED,
|
|
periodDays: null,
|
|
periodCountCalendarDays: false,
|
|
periodStartDate: null,
|
|
periodEndDate: null,
|
|
}}
|
|
/>
|
|
);
|
|
|
|
const selectedMonthLabel = getByTestId("selected-month-label");
|
|
await expect(selectedMonthLabel).toHaveAttribute("dateTime", testDate.format("YYYY-MM"));
|
|
});
|
|
|
|
test("Should render with the minimum date if browsingDate < minDate", async () => {
|
|
const testDate = dayjs("2024-02-20");
|
|
const minDate = dayjs("2025-02-10");
|
|
const { getByTestId } = render(
|
|
<DatePicker onChange={noop} browsingDate={testDate} minDate={minDate.toDate()} locale="en" />
|
|
);
|
|
|
|
const selectedMonthLabel = getByTestId("selected-month-label");
|
|
await expect(selectedMonthLabel).toHaveAttribute("dateTime", minDate.format("YYYY-MM"));
|
|
});
|
|
|
|
test("Should render with the browsingDate date if browsingDate >= minDate", async () => {
|
|
const testDate = dayjs("2025-03-20");
|
|
const minDate = dayjs("2025-02-10");
|
|
const { getByTestId } = render(
|
|
<DatePicker onChange={noop} browsingDate={testDate} minDate={minDate} locale="en" />
|
|
);
|
|
|
|
const selectedMonthLabel = getByTestId("selected-month-label");
|
|
await expect(selectedMonthLabel).toHaveAttribute("dateTime", testDate.format("YYYY-MM"));
|
|
});
|
|
});
|