Files
claude-engineering-plugin/tests/path-sanitization.test.ts
Trevin Chow 5c0ec9137a
Some checks failed
CI / pr-title (push) Has been cancelled
CI / test (push) Has been cancelled
Release PR / release-pr (push) Has been cancelled
Release PR / publish-cli (push) Has been cancelled
refactor(cli)!: rename all skills and agents to consistent ce- prefix (#503)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 15:44:22 -07:00

47 lines
1.5 KiB
TypeScript

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)
})
})