Skip to content

Commit

Permalink
test(date-utils): added missing tests for the safeMultipleDatesFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
mertJF committed Nov 14, 2024
1 parent f730a31 commit b4c988a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/date_utils_test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
getMidnightDate,
registerLocale,
isMonthYearDisabled,
safeMultipleDatesFormat,
} from "../date_utils";

registerLocale("pt-BR", ptBR);
Expand Down Expand Up @@ -1230,6 +1231,33 @@ describe("date_utils", () => {
});
});

describe("safeMultipleDatesFormat", () => {
const props = {
dateFormat: "MM/dd/yyyy",
locale: "en",
};

const dates = [
new Date("2024-11-14 00:00:00"),
new Date("2024-11-15 00:00:00"),
new Date("2024-11-16 00:00:00"),
];

it("should return a blank string when the dates array is null", () => {
expect(safeMultipleDatesFormat([], props)).toBe("");
});

it("should return the correct count when multiple dates are selected", () => {
expect(safeMultipleDatesFormat(dates, props)).toBe("11/14/2024 (+2)");
});

it("should return each selected date when showSelectedCount is false", () => {
expect(
safeMultipleDatesFormat(dates, { ...props, showSelectedCount: false }),
).toBe("11/14/2024, 11/15/2024, 11/16/2024");
});
});

describe("getHolidaysMap", () => {
it("should return a map of dateClasses", () => {
const holidayDates = [
Expand Down
1 change: 1 addition & 0 deletions src/test/min_time_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const DatePickerWithState = (
| "dateFormat"
| "selectsRange"
| "selectsMultiple"
| "showSelectedCount"
| "onSelect"
>,
) => {
Expand Down

0 comments on commit b4c988a

Please sign in to comment.