switch to ical.js and cleanup obsolete files - v0.4.6 [skip-ci]
All checks were successful
Build SilverBullet Plug / build (push) Successful in 11s

This commit is contained in:
2026-02-21 16:05:54 -08:00
parent 30731c7752
commit 139ab71db7
26 changed files with 174 additions and 454 deletions

View File

@@ -1,5 +1,5 @@
import { assertEquals, assert } from "jsr:@std/assert";
import { resolveEventStart, expandRecurrences, localDateString } from "./icalendar.ts";
import { resolveEventStart, expandRecurrences, dateToTimezoneString } from "./icalendar.ts";
Deno.test("resolveEventStart - local date with timezone", async () => {
const icsEvent = {
@@ -47,7 +47,7 @@ Deno.test("resolveEventStart - UTC event", async () => {
Deno.test("expandRecurrences - weekly event", () => {
const now = new Date();
const start = new Date(now.getTime() - 14 * 86400000); // Started 2 weeks ago
const startStr = localDateString(start);
const startStr = dateToTimezoneString(start, "UTC");
const icsEvent = {
summary: "Weekly Meeting",
@@ -68,21 +68,21 @@ Deno.test("expandRecurrences - EXDATE exclusion", () => {
const yesterday = new Date(now.getTime() - 86400000);
const tomorrow = new Date(now.getTime() + 86400000);
const startStr = localDateString(yesterday);
const tomorrowStr = localDateString(tomorrow);
const startStr = dateToTimezoneString(yesterday, "UTC");
const tomorrowStr = dateToTimezoneString(tomorrow, "UTC");
const icsEvent = {
summary: "Daily Meeting EXDATE",
start: startStr,
start: yesterday.toISOString(),
rrule: "FREQ=DAILY;COUNT=3",
exdate: [tomorrowStr]
exdate: [tomorrow.toISOString()]
};
const results = expandRecurrences(icsEvent, 30);
const results = expandRecurrences(icsEvent, 30, "UTC", now);
// Yesterday (in window), Today (in window), Tomorrow (Excluded)
// Should have 2 occurrences
assertEquals(results.length, 2);
assertEquals(results[0].start, startStr);
assertEquals(results[0].startLocal, dateToTimezoneString(yesterday, "UTC"));
});
Deno.test("fetchAndParseCalendar - filter cancelled events", async () => {
@@ -107,15 +107,15 @@ Deno.test("resolveEventStart - ignore tzShift", async () => {
Deno.test("expandRecurrences - custom windowDays", () => {
const now = new Date();
const startStr = localDateString(now);
const start = new Date(now.getTime() - 7 * 86400000); // 7 days ago
const icsEvent = {
summary: "Daily Meeting Window",
start: startStr,
start: start.toISOString(),
rrule: "FREQ=DAILY"
};
const results = expandRecurrences(icsEvent, 2);
const results = expandRecurrences(icsEvent, 2, "UTC", now);
// Today (in window), Tomorrow (in window), Day after tomorrow (in window)
// set.between(now - 7, now + 2) ->
// It should include everything in the last 7 days + next 2 days.
@@ -124,7 +124,7 @@ Deno.test("expandRecurrences - custom windowDays", () => {
});
Deno.test("expandRecurrences - non-string rrule (Reproduction)", () => {
const now = new Date();
const startStr = localDateString(now);
const startStr = dateToTimezoneString(now, "UTC");
const icsEvent = {
summary: "Bug Reproduction Event",
@@ -158,7 +158,7 @@ Deno.test("expandRecurrences - non-string rrule (Reproduction)", () => {
Deno.test("expandRecurrences - validation of visibility logic", () => {
const now = new Date();
const start = new Date(now.getTime() - 100 * 86400000); // Started 100 days ago
const startStr = localDateString(start);
const startStr = dateToTimezoneString(start, "UTC");
const icsEvent = {
summary: "Validation Weekly Meeting",
@@ -177,7 +177,7 @@ Deno.test("expandRecurrences - validation of visibility logic", () => {
Deno.test("expandRecurrences - object rrule (Reproduction of missing events)", () => {
const now = new Date();
const start = new Date(now.getTime() - 100 * 86400000);
const startStr = localDateString(start);
const startStr = dateToTimezoneString(start, "UTC");
const icsEvent = {
summary: "Object RRULE Event",
@@ -210,7 +210,7 @@ Deno.test("expandRecurrences - object rrule (Reproduction of missing events)", (
Deno.test("expandRecurrences - object rrule with until", () => {
const now = new Date();
const start = new Date(now.getTime() - 10 * 86400000);
const startStr = localDateString(start);
const startStr = dateToTimezoneString(start, "UTC");
const untilDate = new Date(now.getTime() + 10 * 86400000);
const icsEvent = {
@@ -229,7 +229,7 @@ Deno.test("expandRecurrences - object rrule with until", () => {
Deno.test("expandRecurrences - object rrule with byday", () => {
const now = new Date();
const start = new Date(now.getTime() - 10 * 86400000);
const startStr = localDateString(start);
const startStr = dateToTimezoneString(start, "UTC");
const icsEvent = {
summary: "Object RRULE BYDAY Event",
@@ -247,7 +247,7 @@ Deno.test("expandRecurrences - object rrule with byday", () => {
Deno.test("expandRecurrences - composite object rrule", () => {
const now = new Date();
const start = new Date(now.getTime() - 10 * 86400000);
const startStr = localDateString(start);
const startStr = dateToTimezoneString(start, "UTC");
const untilDate = new Date(now.getTime() + 10 * 86400000);
const icsEvent = {