import { test } from "node:test"; import assert from "node:assert/strict"; import { parseCustomTheme } from "../src/lib/theme/customThemes.ts"; const palette = { bg: "#123", text: "#abcdef", accent: "#AABBCC" }; const theme = { schema: 1, id: "my-theme", name: "My theme", light: palette, dark: palette }; test("theme files accept explicit color tokens in both appearances", () => { assert.deepEqual(parseCustomTheme(theme), theme); }); test("theme files reject CSS injection, unknown tokens, and incomplete palettes", () => { for (const dark of [{ ...palette, bg: "url(https://invalid.test)" }, { ...palette, position: "fixed" }, { bg: "#000" }, []]) { assert.throws(() => parseCustomTheme({ ...theme, dark })); } assert.throws(() => parseCustomTheme({ ...theme, id: "../unsafe" })); });