fix: combine detailed tender search fields

This commit is contained in:
2026-09-06 15:59:01 +03:00
parent 9b751296ed
commit 3a5b06cee2
8 changed files with 78 additions and 35 deletions
+8 -1
View File
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {normalizeTenderSearch,matchesTenderSearch,matchingItemResults} from '../src/services/tenderSearch.js';
import {normalizeTenderSearch,matchesTenderSearch,matchingItemResults,matchesDetailedSearch} from '../src/services/tenderSearch.js';
test('Turkish search treats case, decomposed characters and spacing consistently across fields',()=>{
for(const value of ['IĞDIR','Iğdır','igdir',' IĞDIR ']) assert.equal(normalizeTenderSearch(value),'igdir');
for(const field of ['baslik','kurum']) assert.equal(matchesTenderSearch({[field]:'IĞDIR İL SAĞLIK'},'ığdır'),true);
@@ -10,6 +10,13 @@ test('Turkish search treats case, decomposed characters and spacing consistently
assert.equal(matchesTenderSearch({},' '),true);
assert.equal(matchesTenderSearch({baslik:'Mikroskop'},'hemogram'),false);
});
test('detailed institution and registration fields are independent and combine with AND',()=>{
const tender={kurum:'IĞDIR İL SAĞLIK MÜDÜRLÜĞÜ',ikn:'2026/1582991'};
assert.equal(matchesDetailedSearch(tender,{institution:'ığdır',registration:'1582991'}),true);
assert.equal(matchesDetailedSearch(tender,{institution:'ığdır',registration:'1534665'}),false);
assert.equal(matchesDetailedSearch(tender,{institution:'kayseri',registration:'1582991'}),false);
assert.equal(matchesDetailedSearch(tender,{institution:'',registration:''}),true);
});
test('old item matches are unavailable immediately when a new query is entered',()=>{
const result={query:normalizeTenderSearch('hemogram'),matches:new Map([['2026/1',[{ad:'Hemogram'}]]])};
assert.equal(matchingItemResults(result,'HEMOGRAM'),result.matches);