Add runtime skin contract and docs
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user