diff --git a/icalendar_test.ts b/icalendar_test.ts index 3927868..5707e11 100644 --- a/icalendar_test.ts +++ b/icalendar_test.ts @@ -225,3 +225,34 @@ Deno.test("expandRecurrences - object rrule with until", () => { assertEquals(results[0].recurrent, true); }); + +Deno.test("expandRecurrences - object rrule with byday (Reproduction)", () => { + const now = new Date(); + const start = new Date(now.getTime() - 10 * 86400000); + const startStr = localDateString(start); + + const icsEvent = { + summary: "Object RRULE BYDAY Event", + start: startStr, + rrule: { frequency: "WEEKLY", byday: [{ day: "MO" }, { day: "WE" }] } + }; + + // Spy on console.error + let errorLogged = false; + const originalConsoleError = console.error; + console.error = (...args) => { + if (args[0].includes("Error expanding recurrence for Object RRULE BYDAY Event") && + args[1].message.includes("Invalid weekday string: [object Object]")) { + errorLogged = true; + } + }; + + try { + expandRecurrences(icsEvent, 30); + } finally { + console.error = originalConsoleError; + } + + assert(errorLogged, "Should have logged an error for invalid BYDAY object values"); +}); +