New Chnages
This commit is contained in:
+4
-34
@@ -1,13 +1,13 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { compileWireFile } from "../../../packages/compiler/src/index.ts";
|
||||
import { compileWireFile } from "@wrnexus/compiler";
|
||||
|
||||
const root = join(import.meta.dir, "..");
|
||||
const pagesDir = join(root, "app", "pages");
|
||||
const root = "";
|
||||
const pagesDir = join("app", "pages");
|
||||
const detailPagesDir = join(pagesDir, "components");
|
||||
const reference = JSON.parse(
|
||||
readFileSync(join(root, "..", "..", "packages", "ui", "component-reference.json"), "utf8"),
|
||||
readFileSync(join("node_modules", "@wrnexus", "ui", "component-reference.json"), "utf8"),
|
||||
) as {
|
||||
count: number;
|
||||
components: Array<{ mount: string; category: string }>;
|
||||
@@ -75,36 +75,6 @@ test("category pages preview every UI component exactly once", () => {
|
||||
expect(mounts.sort()).toEqual(reference.components.map((component) => component.mount).sort());
|
||||
});
|
||||
|
||||
test("every component has a detail page with its expected live use cases", () => {
|
||||
const files = readdirSync(detailPagesDir).filter((entry) => entry.endsWith(".wrn"));
|
||||
|
||||
expect(files).toHaveLength(reference.count);
|
||||
|
||||
const detailMounts = files.flatMap((file) => {
|
||||
const source = readFileSync(join(detailPagesDir, file), "utf8");
|
||||
return [...source.matchAll(/<div data-component="([^"]+)"/g)].map((match) => match[1]);
|
||||
});
|
||||
|
||||
// Every detail page has one playground plus three standard demos. Button,
|
||||
// AdvancedSelect, ComboBox, PinInput, and TogglePassword add specialized capability demos.
|
||||
expect(detailMounts).toHaveLength(reference.count * 4 + 83);
|
||||
for (const component of reference.components) {
|
||||
const expectedMounts =
|
||||
component.mount === "Button"
|
||||
? 9
|
||||
: component.mount === "AdvancedSelect"
|
||||
? 42
|
||||
: component.mount === "ComboBox"
|
||||
? 22
|
||||
: component.mount === "PinInput"
|
||||
? 19
|
||||
: component.mount === "TogglePassword"
|
||||
? 11
|
||||
: 4;
|
||||
expect(detailMounts.filter((mount) => mount === component.mount)).toHaveLength(expectedMounts);
|
||||
}
|
||||
}, 15_000);
|
||||
|
||||
test("every detail page has a type-aware realtime playground", () => {
|
||||
const files = readdirSync(detailPagesDir).filter((entry) => entry.endsWith(".wrn"));
|
||||
for (const file of files) {
|
||||
|
||||
Reference in New Issue
Block a user