Skip to content

Commit 5cabbe7

Browse files
fix: add const assertions for TypeScript literal type inference
1 parent 674827d commit 5cabbe7

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/server/mcp.test.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,26 +1701,38 @@ describe('tool()', () => {
17011701
// Create a new server instance for this test
17021702
const testServer = new McpServer({
17031703
name: 'test server',
1704-
version: '1.0',
1704+
version: '1.0'
17051705
});
17061706

17071707
// Spy on console.warn to verify warnings are logged
17081708
const warnSpy = jest.spyOn(console, 'warn').mockImplementation();
17091709

17101710
// Test valid tool names
1711-
testServer.registerTool('valid-tool-name', {
1712-
description: 'A valid tool name'
1713-
}, async () => ({ content: [{ type: 'text', text: 'Success' }] }));
1711+
testServer.registerTool(
1712+
'valid-tool-name',
1713+
{
1714+
description: 'A valid tool name'
1715+
},
1716+
async () => ({ content: [{ type: 'text' as const, text: 'Success' }] })
1717+
);
17141718

17151719
// Test tool name with warnings (starts with dash)
1716-
testServer.registerTool('-warning-tool', {
1717-
description: 'A tool name that generates warnings'
1718-
}, async () => ({ content: [{ type: 'text', text: 'Success' }] }));
1720+
testServer.registerTool(
1721+
'-warning-tool',
1722+
{
1723+
description: 'A tool name that generates warnings'
1724+
},
1725+
async () => ({ content: [{ type: 'text' as const, text: 'Success' }] })
1726+
);
17191727

17201728
// Test invalid tool name (contains spaces)
1721-
testServer.registerTool('invalid tool name', {
1722-
description: 'An invalid tool name'
1723-
}, async () => ({ content: [{ type: 'text', text: 'Success' }] }));
1729+
testServer.registerTool(
1730+
'invalid tool name',
1731+
{
1732+
description: 'An invalid tool name'
1733+
},
1734+
async () => ({ content: [{ type: 'text' as const, text: 'Success' }] })
1735+
);
17241736

17251737
// Verify that warnings were issued (both for warnings and validation failures)
17261738
expect(warnSpy).toHaveBeenCalled();

0 commit comments

Comments
 (0)