Files
ihaleist/tests/review-state.test.mjs
T

22 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {companyStats,parseDateTR} from '../src/services/analytics.js';
test('analytics rejects impossible Turkish calendar dates instead of rolling them over',()=>{
assert.equal(parseDateTR('31.02.2026'),null);
assert.equal(parseDateTR('29.02.2028')?.getDate(),29);
assert.equal(parseDateTR('30/04/2026')?.getMonth(),3);
});
import {hizliFiltreGecer} from '../src/services/ihaleTarih.js';
import {applyTenderStates} from '../src/services/tenderState.js';
test('review counter uses the same explicit state as reviewed and unread filters',()=>{
const tenders=[{id:'a',incelendi:true},{id:'b',kanbanStatus:'teklif_hazirlaniyor'},{id:'c',incelendi:false,gorev:{}}];
assert.equal(companyStats(tenders).reviewed,1);
assert.equal(tenders.filter(t=>hizliFiltreGecer(t,'incelenenler')).length,1);
assert.equal(tenders.filter(t=>hizliFiltreGecer(t,'incelenmedi')).length,2);
});
test('reviewed tender snapshot survives dropping out of the current source pool',()=>{
const records={'2026/1':{snapshot:{id:'a',ikn:'2026/1',baslik:'Lab'},data:{incelendi:true}}};
const list=applyTenderStates([],records);assert.equal(list.length,1);assert.equal(list[0].incelendi,true);
assert.equal(applyTenderStates(list,records).length,1);
});