feat: release design system engine, studio and component contracts
This commit is contained in:
1 parent
ff1065fb27
commit
3943b946d6
693 files changed
+175546
-3894
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { test, expect } from "bun:test";
|
||||
import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { runDesignCommand } from "../src/design.ts";
|
||||
|
||||
test("design CLI validates data, inspects provenance and compiles without modifying input", async () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), "wrn-design-cli-"));
|
||||
try {
|
||||
const file = join(directory, "system.json");
|
||||
const source = JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
id: "square",
|
||||
name: "Square",
|
||||
version: "1",
|
||||
tokens: { radius: { type: "dimension", value: "0", legacy: "radius-sm" } },
|
||||
});
|
||||
writeFileSync(file, source);
|
||||
expect(JSON.parse(await runDesignCommand(["validate", file])).valid).toBe(true);
|
||||
expect(JSON.parse(await runDesignCommand(["inspect", file])).tokens.radius.source).toBe(
|
||||
"square.tokens.radius",
|
||||
);
|
||||
expect(await runDesignCommand(["compile", file])).toContain("--wrn-radius-sm:0;");
|
||||
expect(await Bun.file(file).text()).toBe(source);
|
||||
await expect(runDesignCommand(["compile", file, "--unknown=x"])).rejects.toThrow(
|
||||
"WRN-DS-OPTION",
|
||||
);
|
||||
writeFileSync(file, source.replace('"0"', '"url(bad)"'));
|
||||
await expect(runDesignCommand(["validate", file])).rejects.toThrow("WRN-DS-VALUE");
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user