Skip to content

Commit e1ab329

Browse files
committed
test: align mocks with CommandExecutor options
1 parent 8333c1a commit e1ab329

59 files changed

Lines changed: 1339 additions & 1190 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/mcp/resources/__tests__/simulators.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { describe, it, expect, beforeEach } from 'vitest';
22
import * as z from 'zod';
33

44
import simulatorsResource, { simulatorsResourceLogic } from '../simulators.ts';
5-
import { createMockExecutor } from '../../../test-utils/mock-executors.ts';
5+
import {
6+
createMockCommandResponse,
7+
createMockExecutor,
8+
} from '../../../test-utils/mock-executors.ts';
69

710
describe('simulators resource', () => {
811
describe('Export Field Validation', () => {
@@ -73,21 +76,19 @@ describe('simulators resource', () => {
7376
const mockExecutor = async (command: string[]) => {
7477
// JSON command returns invalid JSON
7578
if (command.includes('--json')) {
76-
return {
79+
return createMockCommandResponse({
7780
success: true,
7881
output: 'invalid json',
7982
error: undefined,
80-
process: { pid: 12345 },
81-
};
83+
});
8284
}
8385

8486
// Text command returns valid text output
85-
return {
87+
return createMockCommandResponse({
8688
success: true,
8789
output: mockTextOutput,
8890
error: undefined,
89-
process: { pid: 12345 },
90-
};
91+
});
9192
};
9293

9394
const result = await simulatorsResourceLogic(mockExecutor);

src/mcp/tools/device/__tests__/build_device.test.ts

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
import { describe, it, expect, beforeEach } from 'vitest';
88
import * as z from 'zod';
9-
import { createMockExecutor, createNoopExecutor } from '../../../../test-utils/mock-executors.ts';
9+
import {
10+
createMockCommandResponse,
11+
createMockExecutor,
12+
createNoopExecutor,
13+
} from '../../../../test-utils/mock-executors.ts';
1014
import buildDevice, { buildDeviceLogic } from '../build_device.ts';
1115
import { sessionStore } from '../../../../utils/session-store.ts';
1216

@@ -130,24 +134,25 @@ describe('build_device plugin', () => {
130134
it('should verify workspace command generation with mock executor', async () => {
131135
const commandCalls: Array<{
132136
args: string[];
133-
logPrefix: string;
134-
silent: boolean;
137+
logPrefix?: string;
138+
silent?: boolean;
135139
opts: { cwd?: string } | undefined;
136140
}> = [];
137141

138142
const stubExecutor = async (
139143
args: string[],
140-
logPrefix: string,
141-
silent: boolean,
144+
logPrefix?: string,
145+
silent?: boolean,
142146
opts?: { cwd?: string },
147+
detached?: boolean,
143148
) => {
144149
commandCalls.push({ args, logPrefix, silent, opts });
145-
return {
150+
void detached;
151+
return createMockCommandResponse({
146152
success: true,
147153
output: 'Build succeeded',
148154
error: undefined,
149-
process: { pid: 12345 },
150-
};
155+
});
151156
};
152157

153158
await buildDeviceLogic(
@@ -182,24 +187,25 @@ describe('build_device plugin', () => {
182187
it('should verify command generation with mock executor', async () => {
183188
const commandCalls: Array<{
184189
args: string[];
185-
logPrefix: string;
186-
silent: boolean;
190+
logPrefix?: string;
191+
silent?: boolean;
187192
opts: { cwd?: string } | undefined;
188193
}> = [];
189194

190195
const stubExecutor = async (
191196
args: string[],
192-
logPrefix: string,
193-
silent: boolean,
197+
logPrefix?: string,
198+
silent?: boolean,
194199
opts?: { cwd?: string },
200+
detached?: boolean,
195201
) => {
196202
commandCalls.push({ args, logPrefix, silent, opts });
197-
return {
203+
void detached;
204+
return createMockCommandResponse({
198205
success: true,
199206
output: 'Build succeeded',
200207
error: undefined,
201-
process: { pid: 12345 },
202-
};
208+
});
203209
};
204210

205211
await buildDeviceLogic(
@@ -291,24 +297,25 @@ describe('build_device plugin', () => {
291297
it('should include optional parameters in command', async () => {
292298
const commandCalls: Array<{
293299
args: string[];
294-
logPrefix: string;
295-
silent: boolean;
300+
logPrefix?: string;
301+
silent?: boolean;
296302
opts: { cwd?: string } | undefined;
297303
}> = [];
298304

299305
const stubExecutor = async (
300306
args: string[],
301-
logPrefix: string,
302-
silent: boolean,
307+
logPrefix?: string,
308+
silent?: boolean,
303309
opts?: { cwd?: string },
310+
detached?: boolean,
304311
) => {
305312
commandCalls.push({ args, logPrefix, silent, opts });
306-
return {
313+
void detached;
314+
return createMockCommandResponse({
307315
success: true,
308316
output: 'Build succeeded',
309317
error: undefined,
310-
process: { pid: 12345 },
311-
};
318+
});
312319
};
313320

314321
await buildDeviceLogic(

0 commit comments

Comments
 (0)