Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| You choose how g1t looks: Auto follows your system, Light and Dark stay put, set from the account menu, the phone's You and help sheet, Settings → Account or the command palette; the page is drawn in your choice from the first byte, every colour has a light value that reads at 4.5:1 or better, code and diffs are highlighted for both, diagrams and the document editor follow along, the product tour and the g1t mark's avatar stay dark, and Dark is what you see until you choose; the workspaces guide says how. | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { DEFAULT_THEME, THEME_CHOICES, THEME_COOKIE, readTheme, resolvedTheme, themeAttribute, themeCookie } from "./theme.ts"; | |
| 5 | ||
| 6 | test("the cookie keeps auto, light or dark, and anything else is the default", () => { | |
| 7 | for (const choice of THEME_CHOICES) assert.equal(readTheme(choice), choice); | |
| 8 | for (const junk of [null, undefined, "", "LIGHT", "sepia", "dark; Path=/"]) assert.equal(readTheme(junk), DEFAULT_THEME); | |
| 9 | }); | |
| 10 | ||
| 11 | test("the cookie is kept a year, on every path, and secure on https", () => { | |
| 12 | assert.equal(themeCookie("light", true), `${THEME_COOKIE}=light; Path=/; Max-Age=31536000; SameSite=Lax; Secure`); | |
| 13 | assert.equal(themeCookie("auto", false), `${THEME_COOKIE}=auto; Path=/; Max-Age=31536000; SameSite=Lax`); | |
| 14 | }); | |
| 15 | ||
| 16 | test("Light and Dark are data-theme on <html>; Auto leaves it to the system", () => { | |
| 17 | assert.equal(themeAttribute("light"), "light"); | |
| 18 | assert.equal(themeAttribute("dark"), "dark"); | |
| 19 | assert.equal(themeAttribute("auto"), undefined); | |
| 20 | }); | |
| 21 | ||
| 22 | test("a chosen theme is itself; Auto with no browser to ask is dark", () => { | |
| 23 | assert.equal(resolvedTheme("light"), "light"); | |
| 24 | assert.equal(resolvedTheme("dark"), "dark"); | |
| 25 | assert.equal(resolvedTheme("auto"), "dark"); | |
| 26 | }); |