b9699bfb8f
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
26 lines
841 B
TypeScript
26 lines
841 B
TypeScript
import { describe, it, expect, beforeEach } from "vitest";
|
|
import { nextTheme, getInitialTheme } from "./theme.js";
|
|
|
|
describe("nextTheme", () => {
|
|
it("bascule dark <-> light", () => {
|
|
expect(nextTheme("dark")).toBe("light");
|
|
expect(nextTheme("light")).toBe("dark");
|
|
});
|
|
});
|
|
|
|
describe("getInitialTheme", () => {
|
|
beforeEach(() => {
|
|
// @ts-expect-error - environnement node sans localStorage
|
|
delete globalThis.localStorage;
|
|
});
|
|
it("retombe sur dark sans localStorage", () => {
|
|
expect(getInitialTheme()).toBe("dark");
|
|
});
|
|
it("lit la valeur persistée si présente", () => {
|
|
const store: Record<string, string> = { "su-theme": "light" };
|
|
// @ts-expect-error - stub minimal
|
|
globalThis.localStorage = { getItem: (k: string) => store[k] ?? null };
|
|
expect(getInitialTheme()).toBe("light");
|
|
});
|
|
});
|