Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanmay committed Aug 16, 2023
1 parent 7a25cb3 commit 7fe8386
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
14 changes: 4 additions & 10 deletions src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,7 @@ function arraysAreEqual(array1, array2) {
return false;
}

for (let i = 0; i < array1.length; i++) {
if (array1[i] !== array2[i]) {
return false;
}
}

return true;
return array1.every((value, index) => value === array2[index]);
}

/**
Expand All @@ -767,14 +761,14 @@ export function getHolidaysMap(
if (
"className" in classNamesObj &&
classNamesObj["className"] === defaultClassName &&
arraysAreEqual(classNamesObj["holidayName"], [holidayName])
arraysAreEqual(classNamesObj["holidayNames"], [holidayName])
) {
return;
}

classNamesObj["className"] = defaultClassName;
const holidayNameArr = classNamesObj["holidayName"];
classNamesObj["holidayName"] = holidayNameArr
const holidayNameArr = classNamesObj["holidayNames"];
classNamesObj["holidayNames"] = holidayNameArr
? [...holidayNameArr, holidayName]
: [holidayName];
dateClasses.set(key, classNamesObj);
Expand Down
4 changes: 2 additions & 2 deletions src/day.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ export default class Day extends React.Component {
const { day, holidays = new Map() } = this.props;
const compareDt = formatDate(day, "MM.dd.yyyy");
if (holidays.has(compareDt)) {
return holidays.get(compareDt).holidayName
? `${holidays.get(compareDt).holidayName}`
return holidays.get(compareDt).holidayNames.length > 0
? holidays.get(compareDt).holidayNames.join(", ")
: "";
}
return "";
Expand Down
15 changes: 8 additions & 7 deletions test/day_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,14 +1070,14 @@ describe("Day", () => {
"08.15.2023",
{
className: "react-datepicker__day--holidays",
holidayName: ["India's Independence Day"],
holidayNames: ["India's Independence Day"],
},
],
[
"12.25.2023",
{
className: "react-datepicker__day--holidays",
holidayName: ["Christmas"],
holidayNames: ["Christmas"],
},
],
]);
Expand All @@ -1095,23 +1095,24 @@ describe("Day", () => {
"08.15.2023",
{
className: "react-datepicker__day--holidays",
holidayName: ["Holiday 1", "Holiday 2"],
holidayNames: ["Holiday 1", "Holiday 2"],
},
],
[
"12.25.2023",
{
className: "react-datepicker__day--holidays",
holidayName: ["Christmas"],
holidayNames: ["Christmas"],
},
],
]);

const shallowDay = renderDay(day, {
holidays: holidays,
});
console.log("TANMAY: ", shallowDay.debug());
expect(
shallowDay.html().indexOf('title="Holiday 1,Holiday 2"'),
shallowDay.html().indexOf('title="Holiday 1, Holiday 2"'),
).not.equal(-1);
});

Expand All @@ -1122,14 +1123,14 @@ describe("Day", () => {
"08.15.2023",
{
className: "react-datepicker__day--holidays",
holidayName: ["India's Independence Day"],
holidayNames: ["India's Independence Day"],
},
],
[
"12.25.2023",
{
className: "react-datepicker__day--holidays",
holidayName: ["Christmas"],
holidayNames: ["Christmas"],
},
],
]);
Expand Down

0 comments on commit 7fe8386

Please sign in to comment.