evOo-local/apps/web/src/lib/ui-appearance.test.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

38 lines
1.3 KiB
TypeScript

import {
persistAppearancePreference,
resolveAppearancePreference,
UI_APPEARANCE_STORAGE_KEY,
} from "@rakazo/ui-tokens";
import { describe, expect, it } from "vitest";
import { applyResolvedAppearance, readSystemAppearance } from "./ui-appearance";
describe("ui-appearance", () => {
it("treats matching light media as light", () => {
expect(readSystemAppearance({ matches: true })).toBe("light");
expect(readSystemAppearance({ matches: false })).toBe("dark");
});
it("writes data-theme and color-scheme on the root", () => {
const root = {
dataset: {} as DOMStringMap,
style: { colorScheme: "" },
};
applyResolvedAppearance("light", root as unknown as HTMLElement);
expect(root.dataset.theme).toBe("light");
expect(root.style.colorScheme).toBe("light");
});
it("persists preference through storage helpers", () => {
const store = new Map<string, string>();
const storage = {
getItem: (key: string) => store.get(key) ?? null,
setItem: (key: string, value: string) => {
store.set(key, value);
},
};
persistAppearancePreference("dark", storage);
expect(store.get(UI_APPEARANCE_STORAGE_KEY)).toBe("dark");
expect(resolveAppearancePreference({ storage })).toBe("dark");
});
});