36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
// The theme registry and how a stored choice reads. Run by `npm test`, which
|
|
// imports the `.ts` module as it is.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import {
|
|
AUTO_THEME,
|
|
DEFAULT_THEME,
|
|
THEMES,
|
|
themeChoice,
|
|
} from "../../shared/src/settings/themes.ts";
|
|
|
|
test("the default is one of the themes", () => {
|
|
assert.ok(THEMES.some((t) => t.id === DEFAULT_THEME));
|
|
});
|
|
|
|
test("every theme is light or dark, and the ids and labels are distinct", () => {
|
|
for (const t of THEMES) assert.ok(["light", "dark"].includes(t.scheme));
|
|
assert.equal(new Set(THEMES.map((t) => t.id)).size, THEMES.length);
|
|
assert.equal(new Set(THEMES.map((t) => t.label)).size, THEMES.length);
|
|
});
|
|
|
|
test("a theme id and auto read as themselves", () => {
|
|
assert.equal(themeChoice("catppuccin-mocha-mauve"), "catppuccin-mocha-mauve");
|
|
assert.equal(themeChoice(AUTO_THEME), AUTO_THEME);
|
|
});
|
|
|
|
test("the values from before themes existed read as their successors", () => {
|
|
assert.equal(themeChoice("system"), AUTO_THEME);
|
|
assert.equal(themeChoice("light"), "hyperhive-light");
|
|
assert.equal(themeChoice("dark"), "hyperhive-dark");
|
|
});
|
|
|
|
test("an unknown value reads as the fallback", () => {
|
|
assert.equal(themeChoice("blue"), DEFAULT_THEME);
|
|
assert.equal(themeChoice(undefined, "hyperhive-light"), "hyperhive-light");
|
|
});
|