fix calendar discovery parsing and load env config

This commit is contained in:
2026-03-20 16:12:36 +01:00
parent 4735b9ccf2
commit 78a6007afd
6 changed files with 103 additions and 6 deletions

View File

@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import { hasDavNode, toDavText } from "../src/caldav/client.js";
describe("DAV parsing helpers", () => {
it("detects nodes in nested DAV object trees", () => {
const resourcetype = {
collection: "",
calendar: "",
};
expect(hasDavNode(resourcetype, "calendar")).toBe(true);
expect(hasDavNode(resourcetype, "write")).toBe(false);
});
it("detects privileges and components in nested values", () => {
const privileges = {
privilege: [{ read: "" }, { write: "" }],
};
const components = {
comp: [{ "@_name": "VEVENT" }, { "@_name": "VTODO" }],
};
expect(hasDavNode(privileges, "write")).toBe(true);
expect(hasDavNode(components, "VEVENT")).toBe(true);
expect(hasDavNode(components, "VJOURNAL")).toBe(false);
});
it("extracts text from nested DAV displayname values", () => {
expect(toDavText(" Personal Calendar ")).toBe("Personal Calendar");
expect(toDavText({ "#text": "Work" })).toBe("Work");
});
});