Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233import { describe, expect, it } from "vitest";import { themeAttribute, themeFromCookies } from "#lib/theme.ts";
describe("themeFromCookies", () => { it("reads the theme cookie among others", () => { expect(themeFromCookies("a=1; theme=dark; b=2")).toBe("dark"); expect(themeFromCookies("theme=light")).toBe("light"); expect(themeFromCookies("theme=ash")).toBe("ash"); });
it("falls back to auto for missing or unknown values", () => { expect(themeFromCookies(null)).toBe("auto"); expect(themeFromCookies("a=1")).toBe("auto"); expect(themeFromCookies("theme=sepia")).toBe("auto"); expect(themeFromCookies("theme=constructor")).toBe("auto"); });});
describe("themeAttribute", () => { it("only stamps explicit themes", () => { expect(themeAttribute("dark")).toBe(' data-theme="dark"'); expect(themeAttribute("auto")).toBe(""); });
it("stamps a preset on its base mode", () => { expect(themeAttribute("ash")).toBe(' data-theme="dark" data-palette="ash"'); expect(themeAttribute("snow")).toBe(' data-theme="light" data-palette="snow"'); expect(themeAttribute("classic-dark")).toBe( ' data-theme="dark" data-palette="classic-dark"' ); });});