Files
WRNexusJS/packages/design-studio/test/presets.test.ts
T
Clintchiz c765d76a06
Quality / quality (ubuntu-latest) (push) Failing after 10m52s
Quality / quality (windows-latest) (push) Canceled after 0s
feat(studio): add thirteen presets and preview reviewed proposals
2026-10-19 14:51:03 +05:30

36 lines
1.5 KiB
TypeScript

import { expect, test } from "bun:test";
import {
CORE_DESIGN_SYSTEMS,
validateDesignSystem,
compileDesignSystem,
} from "@wrnexus/design-system";
import { STUDIO_PRESETS } from "../src/presets.ts";
import { studioHtml } from "../src/shell.ts";
import { StudioSession } from "../src/session.ts";
test("thirteen distinct Studio presets validate and compile both modes without changing core presets", () => {
expect(Object.keys(STUDIO_PRESETS)).toHaveLength(13);
expect(Object.keys(CORE_DESIGN_SYSTEMS)).toEqual(["square", "soft", "angular"]);
const signatures = new Set<string>();
for (const [id, system] of Object.entries(STUDIO_PRESETS)) {
expect(system.id).toBe(id);
expect(validateDesignSystem(system)).toEqual([]);
expect(studioHtml).toContain(`<option value="${id}">${system.name}</option>`);
signatures.add(JSON.stringify([system.tokens, system.modes]));
for (const mode of ["light", "dark"])
expect(() => compileDesignSystem(system, { mode })).not.toThrow();
}
expect(signatures.size).toBe(13);
});
test("choosing a new preset stays undoable and never mutates the catalog", () => {
const session = new StudioSession(STUDIO_PRESETS.square);
const original = JSON.stringify(STUDIO_PRESETS.swiss);
session.replace(STUDIO_PRESETS.swiss!, "Selected Swiss");
session.edit(JSON.stringify({ ...session.valid, name: "My Swiss" }));
expect(JSON.stringify(STUDIO_PRESETS.swiss)).toBe(original);
session.undo();
session.undo();
expect(session.valid.id).toBe("square");
});