Skip to content

Commit b4c988a

Browse files
committed
test(date-utils): added missing tests for the safeMultipleDatesFormat
1 parent f730a31 commit b4c988a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/test/date_utils_test.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
getMidnightDate,
5252
registerLocale,
5353
isMonthYearDisabled,
54+
safeMultipleDatesFormat,
5455
} from "../date_utils";
5556

5657
registerLocale("pt-BR", ptBR);
@@ -1230,6 +1231,33 @@ describe("date_utils", () => {
12301231
});
12311232
});
12321233

1234+
describe("safeMultipleDatesFormat", () => {
1235+
const props = {
1236+
dateFormat: "MM/dd/yyyy",
1237+
locale: "en",
1238+
};
1239+
1240+
const dates = [
1241+
new Date("2024-11-14 00:00:00"),
1242+
new Date("2024-11-15 00:00:00"),
1243+
new Date("2024-11-16 00:00:00"),
1244+
];
1245+
1246+
it("should return a blank string when the dates array is null", () => {
1247+
expect(safeMultipleDatesFormat([], props)).toBe("");
1248+
});
1249+
1250+
it("should return the correct count when multiple dates are selected", () => {
1251+
expect(safeMultipleDatesFormat(dates, props)).toBe("11/14/2024 (+2)");
1252+
});
1253+
1254+
it("should return each selected date when showSelectedCount is false", () => {
1255+
expect(
1256+
safeMultipleDatesFormat(dates, { ...props, showSelectedCount: false }),
1257+
).toBe("11/14/2024, 11/15/2024, 11/16/2024");
1258+
});
1259+
});
1260+
12331261
describe("getHolidaysMap", () => {
12341262
it("should return a map of dateClasses", () => {
12351263
const holidayDates = [

src/test/min_time_test.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const DatePickerWithState = (
2424
| "dateFormat"
2525
| "selectsRange"
2626
| "selectsMultiple"
27+
| "showSelectedCount"
2728
| "onSelect"
2829
>,
2930
) => {

0 commit comments

Comments
 (0)