test: expand frontmatter coverage

This commit is contained in:
Peter Steinberger
2026-01-17 19:58:53 +00:00
parent 4fdecfb845
commit 1309fc1f48
2 changed files with 48 additions and 0 deletions

View File

@@ -256,4 +256,20 @@ metadata:
expect(clawdbot?.requires?.config).toEqual(["workspace.dir"]);
expect(clawdbot?.install?.[0].kind).toBe("bundled");
});
it("parses YAML metadata map", () => {
const content = `---
name: yaml-metadata
metadata:
clawdbot:
emoji: disk
events:
- command:new
---
`;
const frontmatter = parseFrontmatter(content);
const clawdbot = resolveClawdbotMetadata(frontmatter);
expect(clawdbot?.emoji).toBe("disk");
expect(clawdbot?.events).toEqual(["command:new"]);
});
});

View File

@@ -37,6 +37,38 @@ metadata:
expect(parsed.clawdbot?.emoji).toBe("disk");
});
it("preserves inline JSON values", () => {
const content = `---
name: inline-json
metadata: {"clawdbot": {"events": ["test"]}}
---
`;
const result = parseFrontmatterBlock(content);
expect(result.metadata).toBe('{"clawdbot": {"events": ["test"]}}');
});
it("stringifies YAML objects and arrays", () => {
const content = `---
name: yaml-objects
enabled: true
retries: 3
tags:
- alpha
- beta
metadata:
clawdbot:
events:
- command:new
---
`;
const result = parseFrontmatterBlock(content);
expect(result.enabled).toBe("true");
expect(result.retries).toBe("3");
expect(JSON.parse(result.tags ?? "[]")).toEqual(["alpha", "beta"]);
const parsed = JSON5.parse(result.metadata ?? "") as { clawdbot?: { events?: string[] } };
expect(parsed.clawdbot?.events).toEqual(["command:new"]);
});
it("returns empty when frontmatter is missing", () => {
const content = "# No frontmatter";
expect(parseFrontmatterBlock(content)).toEqual({});