feat: add application productivity foundations
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from "bun:test";
|
||||
import { scaffold } from "../src/generate.ts";
|
||||
import { scaffold, scaffoldResource } from "../src/generate.ts";
|
||||
|
||||
test("scaffold page: kebab file, PascalCase page name", () => {
|
||||
const f = scaffold("page", "about-us");
|
||||
@@ -32,3 +32,15 @@ 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");
|
||||
});
|
||||
|
||||
test("resource scaffold emits schema, handlers, routes and a page", () => {
|
||||
const files = scaffoldResource("templates");
|
||||
expect(files.map((file) => file.path)).toEqual([
|
||||
"schemas/template.ts",
|
||||
"resources/templates.ts",
|
||||
"api/templates.ts",
|
||||
"api/templates/[id].ts",
|
||||
"pages/templates.wrn",
|
||||
]);
|
||||
expect(files[1]?.content).toContain("defineResource");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user