Elffuss BraidHub

kikocis/continue public

fc89067dc2f1 · 2.2 KiBRawPermalink
1import { beforeEach, describe, expect, it } from "vitest";
2
3import { parseArgs } from "./args.js";
4
5describe("parseArgs --mcp flag", () => {
6 beforeEach(() => {
7 // Clear process.argv before each test
8 process.argv = ["node", "test"];
9 });
10
11 it("should parse single MCP from --mcp flag", () => {
12 process.argv = ["node", "test", "--mcp", "my-org/my-mcp"];
13 const result = parseArgs();
14 expect(result.mcps).toEqual(["my-org/my-mcp"]);
15 });
16
17 it("should parse multiple MCPs from multiple --mcp flags", () => {
18 process.argv = ["node", "test", "--mcp", "org1/mcp1", "--mcp", "org2/mcp2"];
19 const result = parseArgs();
20 expect(result.mcps).toEqual(["org1/mcp1", "org2/mcp2"]);
21 });
22
23 it("should handle MCP flag with other flags", () => {
24 process.argv = [
25 "node",
26 "test",
27 "--config",
28 "my-config.yaml",
29 "--mcp",
30 "my-org/my-mcp",
31 "--org",
32 "test-org",
33 ];
34 const result = parseArgs();
35 expect(result.configPath).toBe("my-config.yaml");
36 expect(result.mcps).toEqual(["my-org/my-mcp"]);
37 expect(result.organizationSlug).toBe("test-org");
38 });
39
40 it("should handle MCP flag with prompt", () => {
41 process.argv = [
42 "node",
43 "test",
44 "--mcp",
45 "my-org/my-mcp",
46 "hello world"
47 ];
48 const result = parseArgs();
49 expect(result.mcps).toEqual(["my-org/my-mcp"]);
50 expect(result.prompt).toBe("hello world");
51 });
52
53 it("should ignore MCP and rule flag values when extracting prompt", () => {
54 process.argv = [
55 "node",
56 "test",
57 "actual prompt",
58 "--rule",
59 "my-rule",
60 "--mcp",
61 "my-org/my-mcp"
62 ];
63 const result = parseArgs();
64 expect(result.prompt).toBe("actual prompt");
65 expect(result.rules).toEqual(["my-rule"]);
66 expect(result.mcps).toEqual(["my-org/my-mcp"]);
67 });
68
69 it("should handle MCP flag without value", () => {
70 process.argv = ["node", "test", "--mcp"];
71 const result = parseArgs();
72 expect(result.mcps).toEqual([]);
73 });
74
75 it("should handle MCP flag at the end without value", () => {
76 process.argv = ["node", "test", "my prompt", "--mcp"];
77 const result = parseArgs();
78 expect(result.prompt).toBe("my prompt");
79 expect(result.mcps).toEqual([]);
80 });
81});