35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { test, expect } from "bun:test";
|
|
import { scaffold } from "../src/generate.ts";
|
|
|
|
test("scaffold page: kebab file, PascalCase page name", () => {
|
|
const f = scaffold("page", "about-us");
|
|
expect(f.path).toBe("pages/about-us.wrn");
|
|
expect(f.content).toContain("page AboutUs {");
|
|
expect(f.content).toContain('layout = "public"');
|
|
});
|
|
|
|
test("scaffold component: props + class", () => {
|
|
const f = scaffold("component", "user-card");
|
|
expect(f.path).toBe("components/user-card.wrn");
|
|
expect(f.content).toContain("component UserCard {");
|
|
expect(f.content).toContain('class="wire-user-card"');
|
|
});
|
|
|
|
test("scaffold api: nested path keeps directories, exports GET", () => {
|
|
const f = scaffold("api", "users/list");
|
|
expect(f.path).toBe("api/users/list.ts");
|
|
expect(f.content).toContain("export async function GET");
|
|
});
|
|
|
|
test("scaffold schema: validation object", () => {
|
|
const f = scaffold("schema", "signup");
|
|
expect(f.path).toBe("schemas/signup.ts");
|
|
expect(f.content).toContain('import { v } from "@wrnexus/validation"');
|
|
expect(f.content).toContain("export default v.object(");
|
|
});
|
|
|
|
test("scaffold strips extensions from the given name", () => {
|
|
expect(scaffold("page", "home.wrn").path).toBe("pages/home.wrn");
|
|
expect(scaffold("api", "ping.ts").path).toBe("api/ping.ts");
|
|
});
|