import { describe, expect, test } from 'bun:test'; import { matches } from './useFilter'; // The accent rule is the one that matters on this machine: an address book of Portuguese names is // unsearchable if "jose" does not find "José". describe('matches', () => { test('an empty query keeps everything', () => { expect(matches('', 'anything')).toBe(true); expect(matches(' ', 'anything')).toBe(true); }); test('is case insensitive', () => { expect(matches('RAMIRO', 'Cervejaria Ramiro')).toBe(true); }); test('ignores accents in BOTH directions', () => { expect(matches('jose', 'José Conceição')).toBe(true); expect(matches('josé', 'Jose Conceicao')).toBe(true); expect(matches('conceicao', 'José Conceição')).toBe(true); }); test('every term must match, but they may land in different fields', () => { expect(matches('ana lisboa', 'Ana Silva', 'Lisboa')).toBe(true); expect(matches('ana porto', 'Ana Silva', 'Lisboa')).toBe(false); }); test('skips absent fields rather than matching on "undefined"', () => { expect(matches('undefined', 'Ana Silva', undefined)).toBe(false); }); test('a date is searchable because start is an ISO string', () => { expect(matches('2026-08-29', 'Dinner', undefined, undefined, '2026-08-29T19:00:00Z')).toBe(true); }); });