sh-mcp/packages/knowledge-base/test/dev-client.test.ts

29 lines
1.1 KiB
TypeScript
Raw Normal View History

import { describe, it, expect } from 'vitest';
import { InMemoryKnowledgeBaseClient } from '../src/dev-client.js';
describe('InMemoryKnowledgeBaseClient', () => {
describe('retrieve', () => {
it('returns the seeded passages', async () => {
const client = new InMemoryKnowledgeBaseClient();
const results = await client.retrieve({ query: 'vendor onboarding' });
expect(results).toHaveLength(3);
expect(results[0].source).toBe('s3://sh-mcp-kb/handbook/vendor-onboarding.md');
expect(results[0].score).toBe(0.92);
expect(results[0].passage).toContain('W-9 intake form');
});
it('respects maxResults', async () => {
const client = new InMemoryKnowledgeBaseClient();
const results = await client.retrieve({ query: 'anything', maxResults: 2 });
expect(results).toHaveLength(2);
});
it('defaults to up to 5 results when maxResults is omitted', async () => {
const client = new InMemoryKnowledgeBaseClient();
const results = await client.retrieve({ query: 'anything' });
expect(results.length).toBeLessThanOrEqual(5);
expect(results).toHaveLength(3);
});
});
});