32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { afterEach, describe, expect, it } from "vitest";
|
|
import { applyThemeToDocument, getStoredTheme, resolveTheme } from "./theme";
|
|
|
|
afterEach(() => {
|
|
document.documentElement.removeAttribute("data-theme");
|
|
document.documentElement.removeAttribute("style");
|
|
window.localStorage.clear();
|
|
});
|
|
|
|
describe("theme", () => {
|
|
it("resolves configured themes as static theme definitions", () => {
|
|
const resolved = resolveTheme("mist-blue");
|
|
|
|
expect(resolved.appearance).toBe("light");
|
|
expect(resolved.definition.id).toBe("mist-blue");
|
|
expect(resolved.definition.swatches[0]).toBe("#edf3f7");
|
|
});
|
|
|
|
it("applies the active theme on the document root", () => {
|
|
applyThemeToDocument("mist-blue");
|
|
|
|
expect(document.documentElement.dataset.theme).toBe("mist-blue");
|
|
expect(document.documentElement.style.colorScheme).toBe("light");
|
|
});
|
|
|
|
it("falls back to the default theme when local storage contains an unknown value", () => {
|
|
window.localStorage.setItem("inbox-dashboard-theme", "unknown-theme");
|
|
|
|
expect(getStoredTheme()).toBe("atelier-copper");
|
|
});
|
|
});
|