Skip to content

Commit

Permalink
Fix thanksgiving date logic and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rosslh committed Oct 9, 2024
1 parent 982c08b commit b3ed94c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/occasions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getNthDayOfWeekInMonth = (
dayOfWeek: number,
n: number,
): number => {
const date = new Date(2023, 10, 23);
const date = new Date();
date.setMonth(month - 1);
date.setDate(1);
while (date.getDay() !== dayOfWeek) {
Expand Down
28 changes: 27 additions & 1 deletion tests/specs/sidebar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ const occasions = {
"2023-10-01",
],
"Halloween": ["2023-10-30", "2023-10-31", "2023-11-01"],
"Canadian Thanksgiving": ["2023-10-08", "2023-10-09", "2023-10-10"],
"Canadian Thanksgiving": [
"2023-10-08",
"2023-10-09",
"2023-10-10",
"2024-10-13",
"2024-10-14",
"2024-10-15",
],
"Remembrance Day": ["2023-11-11"],
"Transgender Awareness Week": ["2023-11-13", "2023-11-16", "2023-11-19"],
"Holidays 2023": ["2023-12-10", "2023-12-20", "2023-12-28"],
Expand Down Expand Up @@ -112,3 +119,22 @@ for (let index = 0; index < Object.keys(occasions).length; index += 1) {
});
}
}

test("Sidebar displays normal image on a non-occasion day", async ({
page,
}) => {
const nonOccasionDate = "2023-07-15";
await setBrowserDate(page, nonOccasionDate);

const sidebar = getLocator([page, "sidebar"]);

const normalImage = getLocator([sidebar, "headshot-image"]);

const altText = await normalImage.getAttribute("alt");
expect(altText).toBe("Ross Hill");

const sourcePath = await normalImage.getAttribute("src");
expect(sourcePath).toBe("/headshot.jpg");

await expectCount(normalImage, 1);
});

0 comments on commit b3ed94c

Please sign in to comment.