forked from GitHubMirrors/silverbullet-icalendar
fix(icalendar): Handle non-string rrule property gracefully
This commit is contained in:
@@ -132,23 +132,25 @@ Deno.test("expandRecurrences - non-string rrule (Reproduction)", () => {
|
||||
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;
|
||||
// Spy on console.warn
|
||||
let warningLogged = false;
|
||||
const originalConsoleWarn = console.warn;
|
||||
console.warn = (...args) => {
|
||||
if (args[0].includes("Invalid rrule type (number) for event \"Bug Reproduction Event\"")) {
|
||||
warningLogged = true;
|
||||
}
|
||||
// originalConsoleError(...args); // Keep silent for test
|
||||
// originalConsoleWarn(...args); // Keep silent for test
|
||||
};
|
||||
|
||||
try {
|
||||
expandRecurrences(icsEvent, 30);
|
||||
const result = expandRecurrences(icsEvent, 30);
|
||||
// Should return the original event as fallback
|
||||
assertEquals(result.length, 1);
|
||||
assertEquals(result[0], icsEvent);
|
||||
} finally {
|
||||
console.error = originalConsoleError;
|
||||
console.warn = originalConsoleWarn;
|
||||
}
|
||||
|
||||
assert(errorLogged, "Should have logged an error for non-string rrule");
|
||||
assert(warningLogged, "Should have logged a warning for non-string rrule");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user