import { describe, it, expect } from 'vitest'; import { InMemoryQboClient } from '../src/dev-client.js'; describe('InMemoryQboClient', () => { describe('searchVendors', () => { it('returns all seeded vendors with a totalCount for an empty query', async () => { const client = new InMemoryQboClient(); const result = await client.searchVendors({ query: '' }); expect(result.totalCount).toBe(3); expect(result.vendors.map((v) => v.id)).toEqual(['101', '102', '103']); }); it('filters by case-insensitive substring on displayName', async () => { const client = new InMemoryQboClient(); const result = await client.searchVendors({ query: 'coastal' }); expect(result.totalCount).toBe(1); expect(result.vendors.map((v) => v.displayName)).toEqual(['Coastal Supply & Hardware']); expect(result.vendors[0].taxId).toBe('98-7654321'); }); it('respects maxResults (totalCount reflects all matches, vendors is capped)', async () => { const client = new InMemoryQboClient(); const result = await client.searchVendors({ query: '', maxResults: 2 }); expect(result.vendors).toHaveLength(2); expect(result.totalCount).toBe(3); }); it('returns an empty vendor list with zero totalCount when nothing matches', async () => { const client = new InMemoryQboClient(); const result = await client.searchVendors({ query: 'zzz-nomatch' }); expect(result.vendors).toEqual([]); expect(result.totalCount).toBe(0); }); }); });