Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildIcs, icsToBase64 } from "./ics";
|
||||
|
||||
const base = {
|
||||
uid: "appt-123@hivegrid",
|
||||
start: new Date("2026-07-01T09:00:00Z"),
|
||||
end: new Date("2026-07-01T10:00:00Z"),
|
||||
dtstamp: new Date("2026-06-30T12:00:00Z"),
|
||||
summary: "Wartungstermin",
|
||||
};
|
||||
|
||||
describe("buildIcs (RFC 5545 minimal)", () => {
|
||||
it("emits a single VEVENT with UTC timestamps + CRLF endings", () => {
|
||||
const ics = buildIcs(base);
|
||||
expect(ics).toContain("BEGIN:VCALENDAR");
|
||||
expect(ics).toContain("BEGIN:VEVENT");
|
||||
expect(ics).toContain("UID:appt-123@hivegrid");
|
||||
expect(ics).toContain("DTSTART:20260701T090000Z");
|
||||
expect(ics).toContain("DTEND:20260701T100000Z");
|
||||
expect(ics).toContain("DTSTAMP:20260630T120000Z");
|
||||
expect(ics).toContain("SUMMARY:Wartungstermin");
|
||||
expect(ics).toContain("END:VCALENDAR");
|
||||
expect(ics).toContain("\r\n");
|
||||
});
|
||||
|
||||
it("escapes TEXT special chars (comma, semicolon, newline, backslash)", () => {
|
||||
const ics = buildIcs({ ...base, summary: "A, B; C\\D", description: "line1\nline2" });
|
||||
expect(ics).toContain("SUMMARY:A\\, B\\; C\\\\D");
|
||||
expect(ics).toContain("DESCRIPTION:line1\\nline2");
|
||||
});
|
||||
|
||||
it("includes organizer + attendee when provided", () => {
|
||||
const ics = buildIcs({ ...base, organizerEmail: "host@acme.de", organizerName: "Acme GmbH", attendeeEmail: "kunde@example.com" });
|
||||
expect(ics).toContain("ORGANIZER;CN=Acme GmbH:mailto:host@acme.de");
|
||||
expect(ics).toContain("ATTENDEE;ROLE=REQ-PARTICIPANT:mailto:kunde@example.com");
|
||||
});
|
||||
|
||||
it("omits optional fields when absent", () => {
|
||||
const ics = buildIcs(base);
|
||||
expect(ics).not.toContain("DESCRIPTION:");
|
||||
expect(ics).not.toContain("LOCATION:");
|
||||
expect(ics).not.toContain("ORGANIZER");
|
||||
});
|
||||
|
||||
it("base64-encodes round-trippable content", () => {
|
||||
const ics = buildIcs(base);
|
||||
expect(Buffer.from(icsToBase64(ics), "base64").toString("utf8")).toEqual(ics);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user