MCPcopy Index your code
hub / github.com/anus-dev/ANUS / createMockCommandContext

Function createMockCommandContext

packages/cli/src/test-utils/mockCommandContext.ts:28–105  ·  view source on GitHub ↗
(
  overrides: DeepPartial<CommandContext> = {},
)

Source from the content-addressed store, hash-verified

26 * @returns A complete, mocked CommandContext object.
27 */
28export const createMockCommandContext = (
29 overrides: DeepPartial<CommandContext> = {},
30): CommandContext => {
31 const defaultMocks: CommandContext = {
32 invocation: {
33 raw: '',
34 name: '',
35 args: '',
36 },
37 services: {
38 config: null,
39 settings: { merged: {} } as LoadedSettings,
40 git: undefined as GitService | undefined,
41 logger: {
42 log: vi.fn(),
43 logMessage: vi.fn(),
44 saveCheckpoint: vi.fn(),
45 loadCheckpoint: vi.fn().mockResolvedValue([]),
46 // eslint-disable-next-line @typescript-eslint/no-explicit-any
47 } as any, // Cast because Logger is a class.
48 },
49 ui: {
50 addItem: vi.fn(),
51 clear: vi.fn(),
52 setDebugMessage: vi.fn(),
53 pendingItem: null,
54 setPendingItem: vi.fn(),
55 loadHistory: vi.fn(),
56 toggleCorgiMode: vi.fn(),
57 toggleVimEnabled: vi.fn(),
58 // eslint-disable-next-line @typescript-eslint/no-explicit-any
59 } as any,
60 session: {
61 sessionShellAllowlist: new Set<string>(),
62 stats: {
63 sessionStartTime: new Date(),
64 lastPromptTokenCount: 0,
65 metrics: {
66 models: {},
67 tools: {
68 totalCalls: 0,
69 totalSuccess: 0,
70 totalFail: 0,
71 totalDurationMs: 0,
72 totalDecisions: { accept: 0, reject: 0, modify: 0 },
73 byName: {},
74 },
75 },
76 } as SessionStatsState,
77 },
78 };
79
80 // eslint-disable-next-line @typescript-eslint/no-explicit-any
81 const merge = (target: any, source: any): any => {
82 const output = { ...target };
83
84 for (const key in source) {
85 if (Object.prototype.hasOwnProperty.call(source, key)) {

Calls 1

mergeFunction · 0.85

Tested by

no test coverage detected