mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-09 22:33:37 +00:00
Remove the system color-scheme fallback from the web UI theme boot path. Fabro now uses a saved light/dark preference when present and otherwise starts in dark mode by default. Add a regression test for the shared theme selection helper and refresh the built web assets.
24 lines
820 B
TypeScript
24 lines
820 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { buildThemeBootScript, resolveTheme } from "./theme-selection";
|
|
|
|
describe("resolveTheme", () => {
|
|
test("defaults to dark when no saved theme exists", () => {
|
|
expect(resolveTheme(null)).toBe("dark");
|
|
expect(resolveTheme("system")).toBe("dark");
|
|
});
|
|
|
|
test("uses the saved theme when it is valid", () => {
|
|
expect(resolveTheme("light")).toBe("light");
|
|
expect(resolveTheme("dark")).toBe("dark");
|
|
});
|
|
});
|
|
|
|
describe("buildThemeBootScript", () => {
|
|
test("defaults the boot script to dark without using system preference", () => {
|
|
const script = buildThemeBootScript();
|
|
|
|
expect(script).toContain('localStorage.getItem("fabro-theme")');
|
|
expect(script).toContain('t="dark"');
|
|
expect(script).not.toContain("matchMedia");
|
|
});
|
|
});
|