-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy pathbuilt-in-commands.spec.ts
More file actions
109 lines (92 loc) · 3.93 KB
/
built-in-commands.spec.ts
File metadata and controls
109 lines (92 loc) · 3.93 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { getBuiltInCommands, getBuiltInCommand, getBuiltInCommandNames } from "../built-in-commands"
describe("Built-in Commands", () => {
describe("getBuiltInCommands", () => {
it("should return all built-in commands", async () => {
const commands = await getBuiltInCommands()
expect(commands).toHaveLength(2)
expect(commands.map((cmd) => cmd.name)).toEqual(expect.arrayContaining(["init", "plugin"]))
// Verify all commands have required properties
commands.forEach((command) => {
expect(command.name).toBeDefined()
expect(typeof command.name).toBe("string")
expect(command.content).toBeDefined()
expect(typeof command.content).toBe("string")
expect(command.source).toBe("built-in")
expect(command.filePath).toMatch(/^<built-in:.+>$/)
expect(command.description).toBeDefined()
expect(typeof command.description).toBe("string")
})
})
it("should return commands with proper content", async () => {
const commands = await getBuiltInCommands()
const initCommand = commands.find((cmd) => cmd.name === "init")
expect(initCommand).toBeDefined()
expect(initCommand!.content).toContain("AGENTS.md")
expect(initCommand!.content).toContain(".roo/rules-")
expect(initCommand!.description).toBe(
"Analyze codebase and create concise AGENTS.md files for AI assistants",
)
const pluginCommand = commands.find((cmd) => cmd.name === "plugin")
expect(pluginCommand).toBeDefined()
expect(pluginCommand!.content).toContain("plugin.json")
expect(pluginCommand!.content).toContain("PluginManager")
expect(pluginCommand!.description).toBe("Install, remove, or list plugins from GitHub repositories")
})
})
describe("getBuiltInCommand", () => {
it("should return specific built-in command by name", async () => {
const initCommand = await getBuiltInCommand("init")
expect(initCommand).toBeDefined()
expect(initCommand!.name).toBe("init")
expect(initCommand!.source).toBe("built-in")
expect(initCommand!.filePath).toBe("<built-in:init>")
expect(initCommand!.content).toContain("AGENTS.md")
expect(initCommand!.description).toBe(
"Analyze codebase and create concise AGENTS.md files for AI assistants",
)
})
it("should return undefined for non-existent command", async () => {
const nonExistentCommand = await getBuiltInCommand("non-existent")
expect(nonExistentCommand).toBeUndefined()
})
it("should handle empty string command name", async () => {
const emptyCommand = await getBuiltInCommand("")
expect(emptyCommand).toBeUndefined()
})
})
describe("getBuiltInCommandNames", () => {
it("should return all built-in command names", async () => {
const names = await getBuiltInCommandNames()
expect(names).toHaveLength(2)
expect(names).toEqual(expect.arrayContaining(["init", "plugin"]))
// Order doesn't matter since it's based on filesystem order
expect(names.sort()).toEqual(["init", "plugin"])
})
it("should return array of strings", async () => {
const names = await getBuiltInCommandNames()
names.forEach((name) => {
expect(typeof name).toBe("string")
expect(name.length).toBeGreaterThan(0)
})
})
})
describe("Command Content Validation", () => {
it("init command should have comprehensive content", async () => {
const command = await getBuiltInCommand("init")
const content = command!.content
// Should contain key sections
expect(content).toContain("Please analyze this codebase")
expect(content).toContain("Build/lint/test commands")
expect(content).toContain("Code style guidelines")
expect(content).toContain("non-obvious")
expect(content).toContain("discovered by reading files")
// Should mention important concepts
expect(content).toContain("AGENTS.md")
expect(content).toContain(".roo/rules-")
expect(content).toContain("rules-code")
expect(content).toContain("rules-debug")
expect(content).toContain("rules-ask")
expect(content).toContain("rules-architect")
})
})
})