forked from EveryInc/compound-engineering-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath-sanitization.test.ts
More file actions
46 lines (37 loc) · 1.54 KB
/
Copy pathpath-sanitization.test.ts
File metadata and controls
46 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { describe, expect, test } from "bun:test"
import path from "path"
import { loadClaudePlugin } from "../src/parsers/claude"
import { sanitizePathName } from "../src/utils/files"
const pluginRoot = path.join(process.cwd(), "plugins", "compound-engineering")
describe("sanitizePathName", () => {
test("replaces colons with hyphens", () => {
expect(sanitizePathName("other:skill")).toBe("other-skill")
expect(sanitizePathName("other:tool")).toBe("other-tool")
})
test("no CE skill name contains a colon", async () => {
const plugin = await loadClaudePlugin(pluginRoot)
for (const skill of plugin.skills) {
expect(skill.name).not.toContain(":")
}
})
test("passes through names without colons", () => {
expect(sanitizePathName("frontend-design")).toBe("frontend-design")
})
test("handles multiple colons", () => {
expect(sanitizePathName("a:b:c")).toBe("a-b-c")
})
})
describe("path sanitization collision detection", () => {
test("no two skill names collide after sanitization", async () => {
const plugin = await loadClaudePlugin(pluginRoot)
const sanitized = plugin.skills.map((skill) => sanitizePathName(skill.name))
const unique = new Set(sanitized)
expect(unique.size).toBe(sanitized.length)
})
test("no two agent names collide after sanitization", async () => {
const plugin = await loadClaudePlugin(pluginRoot)
const sanitized = plugin.agents.map((agent) => sanitizePathName(agent.name))
const unique = new Set(sanitized)
expect(unique.size).toBe(sanitized.length)
})
})