fix(smartfuzzy): handle empty search strings safely and update tests for stricter TypeScript compatibility

This commit is contained in:
2026-05-01 16:02:29 +00:00
parent 58109bd7e0
commit 31c7865d88
12 changed files with 3676 additions and 4989 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
import { expect, tap } from '@push.rocks/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartfuzzy from '../ts/index.js';
class Car {
@@ -73,11 +73,11 @@ tap.test('should sort objects by multiple field search', async () => {
// fuzzy matching algorithm's threshold setting
// BMW should be the first result
const bmwIndex = result.findIndex(r => r.item.brand === 'BMW');
const bmwIndex = result.findIndex((fuzzyResult) => fuzzyResult.item.brand === 'BMW');
expect(bmwIndex).toEqual(0);
// If Toyota is in results, it should be ranked lower than BMW
const toyotaIndex = result.findIndex(r => r.item.brand === 'Toyota');
const toyotaIndex = result.findIndex((fuzzyResult) => fuzzyResult.item.brand === 'Toyota');
if (toyotaIndex !== -1) {
expect(bmwIndex).toBeLessThan(toyotaIndex);
}