test: add MCP call tests for each search tool

This commit is contained in:
Sampson committed 2026-08-11 13:24:52 -05:00
1 parent 38d703263d
commit 896ac6acd3
8 files changed
+361

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { connectTestClient, stubFetch } from '../../testUtils/mcpTestHarness.js';
import { name } from './index.js';
describe(name, () => {
let client: Client;
let close: () => Promise<void>;
let restoreFetch: () => void;
before(async () => {
restoreFetch = stubFetch((url) => {
if (url.pathname === '/res/v1/local/place_search') {
return { type: 'locations' };
}
});
({ client, close } = await connectTestClient());
});
after(async () => {
restoreFetch();
await close();
});
it('returns a locations response for a simple location query', async () => {
const result = await client.callTool({
name,
arguments: { location: 'san francisco ca united states' },
});
assert.equal(result.isError ?? false, false, JSON.stringify(result.content));
assert.ok(Array.isArray(result.content) && result.content.length > 0);
});
});