mirror of
https://github.com/Sea-Haven-Industries/sh-mcp.git
synced 2026-10-07 11:38:58 +00:00
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
|
|
import { describe, it, expect } from 'vitest';
|
||
|
|
import { InMemoryGoogleMapsClient } from '../src/dev-client.js';
|
||
|
|
|
||
|
|
describe('InMemoryGoogleMapsClient', () => {
|
||
|
|
describe('searchText', () => {
|
||
|
|
it('returns all seeded places for an empty query', async () => {
|
||
|
|
const client = new InMemoryGoogleMapsClient();
|
||
|
|
const results = await client.searchText({ textQuery: '' });
|
||
|
|
expect(results.map((p) => p.displayName)).toEqual([
|
||
|
|
'Harbor Electric Co.',
|
||
|
|
'Coastal Supply & Hardware',
|
||
|
|
'Tidewater Plumbing LLC',
|
||
|
|
]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('filters by case-insensitive substring on displayName', async () => {
|
||
|
|
const client = new InMemoryGoogleMapsClient();
|
||
|
|
const results = await client.searchText({ textQuery: 'harbor' });
|
||
|
|
expect(results.map((p) => p.displayName)).toEqual(['Harbor Electric Co.']);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('filters by place type', async () => {
|
||
|
|
const client = new InMemoryGoogleMapsClient();
|
||
|
|
const results = await client.searchText({ textQuery: 'plumber' });
|
||
|
|
expect(results.map((p) => p.displayName)).toEqual(['Tidewater Plumbing LLC']);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('falls back to all seeded places when nothing matches', async () => {
|
||
|
|
const client = new InMemoryGoogleMapsClient();
|
||
|
|
const results = await client.searchText({ textQuery: 'zzz-nomatch' });
|
||
|
|
expect(results).toHaveLength(3);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('respects maxResultCount', async () => {
|
||
|
|
const client = new InMemoryGoogleMapsClient();
|
||
|
|
const results = await client.searchText({ textQuery: '', maxResultCount: 2 });
|
||
|
|
expect(results).toHaveLength(2);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|