muddle/tests/templates-generator.test.ts
2026-10-23 09:12:49 -04:00

34 lines
1.1 KiB
TypeScript

import { expect, test } from "bun:test";
import { mkdtemp, readFile, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { createTemplate } from "../core/templates.ts";
test("creates the responsive documentation template", async () => {
const root = await mkdtemp(join(tmpdir(), "muddle-docs-"));
try {
const result = await createTemplate("docs", root);
expect(result.files.length).toBeGreaterThan(6);
const view = await readFile(
join(root, "modules/app/views/index.spug"),
"utf8",
);
const styles = await readFile(join(root, "styles/app.stcss"), "utf8");
expect(view).toContain("@docs.{section.id}");
expect(styles).toContain(":reflect(@docs)");
} finally {
await rm(root, { recursive: true, force: true });
}
});
test("creates the minimal template", async () => {
const root = await mkdtemp(join(tmpdir(), "muddle-minimal-"));
try {
await createTemplate("minimal", root);
expect(await readFile(join(root, "index.ts"), "utf8")).toContain(
"export const app",
);
} finally {
await rm(root, { recursive: true, force: true });
}
});