Files
ihaleist/tests/preparation-deadline.test.mjs
T

24 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {test} from 'node:test';
import assert from 'node:assert/strict';
import {preparationDeadlineProblem} from '../src/services/preparationDeadline.js';
const tender={tarih:'10.09.2026',saat:'10:00',durum:'Açık'};
test('readiness closes at the exact Istanbul deadline, including during output generation',()=>{
assert.equal(preparationDeadlineProblem(tender,new Date('2026-09-10T06:59:59.999Z')),null);
assert.match(preparationDeadlineProblem(tender,new Date('2026-09-10T07:00:00Z')),/zamanı geçti/);
});
test('unknown or malformed deadline cannot qualify as a ready bid',()=>{
for(const value of [{tarih:'31.02.2026',saat:'10:00'},{tarih:'10.09.2026'},{tarih:'10.09.2026abc',saat:'10:00'},{tarih:'10.09.2026',saat:'10:0099'}])
assert.match(preparationDeadlineProblem(value,new Date('2026-09-01')),/doğrulanamadı/);
});
test('cancelled and completed tenders do not regain readiness merely through a future date',()=>{
for(const durum of ['İptal Edildi','Sonuçlandı','Sözleşme imzalandı'])
assert.match(preparationDeadlineProblem({...tender,durum},new Date('2026-09-01')),/iptal edilmiş veya sonuçlanmış/);
});
test('published winner blocks readiness even when the source status and date still appear open',()=>{
const now=new Date('2026-09-01');
for(const durum of ['Açık','',undefined])
assert.match(preparationDeadlineProblem({...tender,durum,kazananFirma:'QA Laboratuvar'},now),/kazananı açıklanmış/);
assert.equal(preparationDeadlineProblem({...tender,kazananFirma:''},now),null);
});