import { describe, expect, it } from 'vitest' import { matchItems, type PaletteItem } from '../src/palette-match' const items: PaletteItem[] = [ { id: 'nav:dash', label: 'Dashboard', group: 'Go to' }, { id: 'nav:clients', label: 'Clients', group: 'Go to' }, { id: 'act:newdoc', label: 'New document', group: 'Actions', hint: 'quotation proforma invoice' }, { id: 'client:1', label: 'CL-0007 ยท Hamiltel', group: 'Clients' }, ] describe('matchItems', () => { it('returns everything (to limit) for an empty query', () => { expect(matchItems(items, '').map((i) => i.id)).toEqual(['nav:dash', 'nav:clients', 'act:newdoc', 'client:1']) expect(matchItems(items, '', 2)).toHaveLength(2) }) it('matches case-insensitively on label', () => { expect(matchItems(items, 'hamil').map((i) => i.id)).toEqual(['client:1']) }) it('matches on hint text too', () => { expect(matchItems(items, 'proforma').map((i) => i.id)).toEqual(['act:newdoc']) }) it('matches every whitespace-separated term (AND)', () => { expect(matchItems(items, 'new doc').map((i) => i.id)).toEqual(['act:newdoc']) expect(matchItems(items, 'new xyz')).toHaveLength(0) }) })