Add runtime skin contract and docs

This commit is contained in:
2026-03-20 11:22:03 +08:00
parent 5c9eb84c63
commit 246851a68e
9 changed files with 1053 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import { defaultSkin, setSkin, skinDetails, skinNames } from "./skin";
describe("skin contract", () => {
it("exposes a default skin that exists in the public name set", () => {
expect(skinNames).toContain(defaultSkin);
expect(skinDetails[defaultSkin].label).toBeTruthy();
});
it("sets the document root skin when no target element is provided", () => {
setSkin("glass");
expect(document.documentElement.dataset.skin).toBe("glass");
});
it("sets the provided target element instead of the document root", () => {
const target = document.createElement("div");
setSkin("pixel", target);
expect(target.dataset.skin).toBe("pixel");
});
});