Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

16 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { THEME_COOKIE, readTheme, themeAttribute, themeCookie } from "./theme.ts";
5
6test("the theme: the cookie's choice, else Auto; Light and Dark on <html>, Auto nothing", () => {
7 assert.equal(readTheme("light"), "light");
8 assert.equal(readTheme("dark"), "dark");
9 assert.equal(readTheme("auto"), "auto");
10 assert.equal(readTheme("sepia"), "auto");
11 assert.equal(readTheme(null), "auto");
12 assert.equal(themeAttribute("light"), "light");
13 assert.equal(themeAttribute("auto"), undefined);
14 assert.equal(themeCookie("dark", true), `${THEME_COOKIE}=dark; Path=/; Max-Age=31536000; SameSite=Lax; Secure`);
15 assert.ok(!themeCookie("dark", false).includes("Secure"));
16});