forked from GitHubMirrors/silverbullet-icalendar
test(icalendar): Add reproduction test for non-string rrule
This commit is contained in:
@@ -121,4 +121,34 @@ Deno.test("expandRecurrences - custom windowDays", () => {
|
|||||||
// It should include everything in the last 7 days + next 2 days.
|
// It should include everything in the last 7 days + next 2 days.
|
||||||
// Since it's daily, that's roughly 7 + 2 + 1 = 10 events.
|
// Since it's daily, that's roughly 7 + 2 + 1 = 10 events.
|
||||||
assert(results.length >= 3, "Should have at least today and 2 future days");
|
assert(results.length >= 3, "Should have at least today and 2 future days");
|
||||||
});
|
});
|
||||||
|
Deno.test("expandRecurrences - non-string rrule (Reproduction)", () => {
|
||||||
|
const now = new Date();
|
||||||
|
const startStr = localDateString(now);
|
||||||
|
|
||||||
|
const icsEvent = {
|
||||||
|
summary: "Bug Reproduction Event",
|
||||||
|
start: startStr,
|
||||||
|
rrule: 12345 // Simulating the malformed data
|
||||||
|
};
|
||||||
|
|
||||||
|
// Spy on console.error
|
||||||
|
let errorLogged = false;
|
||||||
|
const originalConsoleError = console.error;
|
||||||
|
console.error = (...args) => {
|
||||||
|
if (args[0].includes("Error expanding recurrence for Bug Reproduction Event") &&
|
||||||
|
args[1] instanceof TypeError) {
|
||||||
|
errorLogged = true;
|
||||||
|
}
|
||||||
|
// originalConsoleError(...args); // Keep silent for test
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
expandRecurrences(icsEvent, 30);
|
||||||
|
} finally {
|
||||||
|
console.error = originalConsoleError;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(errorLogged, "Should have logged an error for non-string rrule");
|
||||||
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user