Skip to content

Commit 75ed1cd

Browse files
fix: resolve linting errors and resource handler dependency injection
- Fix ESLint errors by replacing Function types with explicit signatures - Fix Prettier formatting issues in test file - Fix resource handler dependency injection to support test mocking - Ensure MCP server compatibility while enabling createMockExecutor() usage - All tests now follow CLAUDE.md dependency injection guidelines Co-authored-by: Cameron Cooke <cameroncooke@users.noreply.github.com>
1 parent 9f9bf79 commit 75ed1cd

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/core/__tests__/resources.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ describe('resources', () => {
6161
let capturedUri: string | undefined;
6262
let capturedDescription: string | undefined;
6363
let capturedOptions: { mimeType: string } | undefined;
64-
let capturedHandler: Function | undefined;
64+
let capturedHandler:
65+
| ((executor?: any) => Promise<{ contents: Array<{ type: 'text'; text: string }> }>)
66+
| undefined;
6567

6668
// Capture the registration call parameters
67-
mockServer.resource = (uri: string, description: string, options: { mimeType: string }, handler: Function) => {
69+
mockServer.resource = (
70+
uri: string,
71+
description: string,
72+
options: { mimeType: string },
73+
handler: (executor?: any) => Promise<{ contents: Array<{ type: 'text'; text: string }> }>,
74+
) => {
6875
capturedUri = uri;
6976
capturedDescription = description;
7077
capturedOptions = options;
@@ -93,10 +100,17 @@ describe('resources', () => {
93100
});
94101

95102
describe('Simulators Resource Handler', () => {
96-
let resourceHandler: (executor?: any) => Promise<{ contents: Array<{ type: 'text'; text: string }> }>;
103+
let resourceHandler: (
104+
executor?: any,
105+
) => Promise<{ contents: Array<{ type: 'text'; text: string }> }>;
97106

98107
beforeEach(() => {
99-
mockServer.resource = (_uri: string, _description: string, _options: { mimeType: string }, handler: Function) => {
108+
mockServer.resource = (
109+
_uri: string,
110+
_description: string,
111+
_options: { mimeType: string },
112+
handler: (executor?: any) => Promise<{ contents: Array<{ type: 'text'; text: string }> }>,
113+
) => {
100114
resourceHandler = handler;
101115
};
102116
registerResources(mockServer);
@@ -256,4 +270,4 @@ describe('resources', () => {
256270
expect(result.contents[0].text).toContain('get_sim_app_path_id_proj');
257271
});
258272
});
259-
});
273+
});

src/core/resources.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ async function handleSimulatorsResource(executor?: CommandExecutor): Promise<{
8080
export function registerResources(server: McpServer): void {
8181
log('info', 'Registering MCP resources');
8282

83-
// Register simulators resource
83+
// Register simulators resource with wrapper to support dependency injection in tests
8484
server.resource(
8585
RESOURCE_URIS.SIMULATORS,
8686
'Available iOS simulators with their UUIDs and states',
8787
{ mimeType: 'text/plain' },
88-
handleSimulatorsResource,
88+
(executor?: CommandExecutor) => handleSimulatorsResource(executor),
8989
);
9090

9191
log('info', `Registered resource: ${RESOURCE_URIS.SIMULATORS}`);

0 commit comments

Comments
 (0)