cb5bbbf382
- Eliminated core/ directory (252 files, 23 subdirs → distributed)
- Reduced max nesting from 9 levels to 5 levels
- Promoted tool subdirs to top level: exa/, lsp/, patch/, task/, web/
- Merged web-scrapers/ + web-search/ into web/{scrapers,search}/
- Flattened modes/interactive/ to modes/
- Split execution/ into: ipy/ (python), exec/ (bash), ssh/
- Renamed ipy/python-*.ts to ipy/*.ts (executor, kernel, etc.)
- Flattened cursor/exec-bridge.ts to cursor.ts
- Created logical groupings: config/, session/, extensibility/, export/
- Updated all imports across 500+ files
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { renderTemplate } from "$c/task/template";
|
|
|
|
describe("renderTemplate", () => {
|
|
test("renders explicit args", () => {
|
|
const result = renderTemplate("Hello {{name}}", { id: "Test", description: "A test", args: { name: "Ada" } });
|
|
expect(result.task).toBe("Hello Ada");
|
|
expect(result.args).toEqual({ id: "Test", description: "A test", name: "Ada" });
|
|
});
|
|
|
|
test("renders id placeholder", () => {
|
|
const result = renderTemplate("Task: {{id}}", { id: "MyTask", description: "Does stuff" });
|
|
expect(result.task).toBe("Task: MyTask");
|
|
});
|
|
|
|
test("renders description placeholder", () => {
|
|
const result = renderTemplate("{{description}}", { id: "X", description: "The description" });
|
|
expect(result.task).toBe("The description");
|
|
});
|
|
|
|
test("throws on unknown placeholders", () => {
|
|
expect(() => renderTemplate("{{unknown}}", { id: "Test", description: "A test" })).toThrow(
|
|
'Task "Test" has unknown arguments: unknown',
|
|
);
|
|
});
|
|
|
|
test("appends assignment block when no placeholders used", () => {
|
|
const result = renderTemplate("Do the thing", { id: "TaskA", description: "First task" });
|
|
expect(result.task).toContain("----------------------");
|
|
expect(result.task).toContain("# TaskA");
|
|
expect(result.task).toContain("First task");
|
|
});
|
|
|
|
test("does not append assignment block when placeholders used", () => {
|
|
const result = renderTemplate("Do {{id}}", { id: "TaskA", description: "First task" });
|
|
expect(result.task).toBe("Do TaskA");
|
|
expect(result.task).not.toContain("----------------------");
|
|
});
|
|
|
|
test("explicit args override id/description", () => {
|
|
const result = renderTemplate("{{id}}", { id: "Real", description: "Real desc", args: { id: "Custom" } });
|
|
expect(result.task).toBe("Custom");
|
|
});
|
|
});
|