Files
TREK/client/src/utils/placeSearch.test.ts
T
Maurice f7782b9ef7 feat(planner): the places search also finds the description and the notes
The search box of the places list matched only name and address. It now also reads what was written about a place, through one helper the desktop list, its filter counts and the phone's browser share. (#2252)
2026-10-01 09:30:42 +02:00

35 lines
1.3 KiB
TypeScript

// FE-UTIL-PLACESEARCH-001 to FE-UTIL-PLACESEARCH-004
import { describe, it, expect } from 'vitest'
import { placeMatchesSearch } from './placeSearch'
const place = {
name: 'Café Central',
address: 'Herrengasse 14, Wien',
description: 'Classic Viennese coffee house',
notes: 'Book a table ahead',
}
describe('placeMatchesSearch', () => {
it('FE-UTIL-PLACESEARCH-001: an empty or blank query matches every place', () => {
expect(placeMatchesSearch(place, '')).toBe(true)
expect(placeMatchesSearch(place, ' ')).toBe(true)
})
it('FE-UTIL-PLACESEARCH-002: finds the name and the address, ignoring case', () => {
expect(placeMatchesSearch(place, 'central')).toBe(true)
expect(placeMatchesSearch(place, 'HERRENGASSE')).toBe(true)
})
it('FE-UTIL-PLACESEARCH-003: also finds the description and the notes (#2252)', () => {
expect(placeMatchesSearch(place, 'viennese')).toBe(true)
expect(placeMatchesSearch(place, 'table ahead')).toBe(true)
})
it('FE-UTIL-PLACESEARCH-004: missing fields are skipped, and a miss is a miss', () => {
const bare = { name: 'Stop', address: null, description: undefined, notes: null }
expect(placeMatchesSearch(bare, 'stop ')).toBe(true)
expect(placeMatchesSearch(bare, 'nowhere')).toBe(false)
expect(placeMatchesSearch(place, 'pizza')).toBe(false)
})
})