fix(smartfuzzy): handle empty search strings safely and update tests for stricter TypeScript compatibility
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user