@orbit-build/cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,107 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { CommandRouter } from "./CommandRouter.js";
3
-
4
- describe("CommandRouter Unit Tests", () => {
5
- const mockConfig = {
6
- language: "en",
7
- permissions: { mode: "strict" },
8
- models: { default: "gpt-4" },
9
- };
10
-
11
- const mockProvider = {
12
- id: "openai",
13
- chat: vi.fn(),
14
- };
15
-
16
- const mockLoop = {
17
- getConfig: () => mockConfig,
18
- getModelOverride: () => undefined,
19
- getHistory: () => [],
20
- getCheckpoints: () => [],
21
- getRelevantFiles: () => [],
22
- addRelevantFilePublic: vi.fn(),
23
- };
24
-
25
- const mockTui = {
26
- isActive: true,
27
- addSystemMessage: vi.fn(),
28
- addLog: vi.fn(),
29
- syncFromLoop: vi.fn(),
30
- setCandidates: vi.fn(),
31
- };
32
-
33
- const mockInteraction = {
34
- askApproval: vi.fn(),
35
- showText: vi.fn(),
36
- showDiff: vi.fn(),
37
- };
38
-
39
- const localState = { lastSessionId: "123", lastModel: "gpt-4" };
40
-
41
- it("should output help message when /help is executed", async () => {
42
- const router = new CommandRouter(
43
- "/dummy/cwd",
44
- mockConfig,
45
- mockProvider,
46
- vi.fn(),
47
- mockLoop as any,
48
- mockTui as any,
49
- false,
50
- () => ({ commands: [], files: [], symbols: [], sessions: [] }),
51
- vi.fn(),
52
- () => localState,
53
- vi.fn(),
54
- mockInteraction as any,
55
- false
56
- );
57
-
58
- const result = await router.route("/help");
59
- expect(result.processed).toBe(true);
60
- expect(result.shouldExit).toBe(false);
61
- expect(mockTui.addSystemMessage).toHaveBeenCalled();
62
- });
63
-
64
- it("should return processed: false for non-slash command inputs", async () => {
65
- const router = new CommandRouter(
66
- "/dummy/cwd",
67
- mockConfig,
68
- mockProvider,
69
- vi.fn(),
70
- mockLoop as any,
71
- mockTui as any,
72
- false,
73
- () => ({ commands: [], files: [], symbols: [], sessions: [] }),
74
- vi.fn(),
75
- () => localState,
76
- vi.fn(),
77
- mockInteraction as any,
78
- false
79
- );
80
-
81
- const result = await router.route("create a login page");
82
- expect(result.processed).toBe(false);
83
- expect(result.shouldExit).toBe(false);
84
- });
85
-
86
- it("should output error message for unknown command", async () => {
87
- const router = new CommandRouter(
88
- "/dummy/cwd",
89
- mockConfig,
90
- mockProvider,
91
- vi.fn(),
92
- mockLoop as any,
93
- mockTui as any,
94
- false,
95
- () => ({ commands: [], files: [], symbols: [], sessions: [] }),
96
- vi.fn(),
97
- () => localState,
98
- vi.fn(),
99
- mockInteraction as any,
100
- false
101
- );
102
-
103
- const result = await router.route("/invalidcommand");
104
- expect(result.processed).toBe(true);
105
- expect(result.shouldExit).toBe(false);
106
- });
107
- });