| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { THEME_COOKIE, readTheme, themeAttribute, themeCookie } from "./theme.ts"; |
| 5 | |
| 6 | test("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 | }); |