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

20 lines
1.6 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 {preparationBlockers,documentKey,HEALTH_CHECKS} from '../src/services/preparationChecks.js';
const rows=[{priceKey:'kit1',name:'Kit'}];
const docs=[{document:'Yetki belgesi',mandatory:true,note:'Şartname 7.1'}];
const complete=()=>({documents:{[documentKey(docs[0])]:{status:'verified',evidence:'Yetki v2, süre kontrol edildi, 7.1'}},products:{kit1:{product:'QA model',source:'Teknik 3.2, katalog s4',status:'suitable',...Object.fromEntries(HEALTH_CHECKS.map(([key])=>[key,{status:'notApplicable',evidence:'Doküman ilgili maddesi kapsamında uygulanmıyor'}]))}}});
test('priced rows without document and health review remain incomplete',()=>{
assert.ok(preparationBlockers(rows,[],{}).length>=6);
assert.equal(preparationBlockers(rows,docs,complete()).length,0);
});
test('unsuitable product, missing evidence and mandatory document exemption block readiness',()=>{
const c=complete();c.products.kit1.status='unsuitable';assert.ok(preparationBlockers(rows,docs,c).some(x=>x.includes('uygun değil')));
c.products.kit1.status='suitable';c.products.kit1.uts.evidence=' ';assert.ok(preparationBlockers(rows,docs,c).some(x=>x.includes('ÜTS')));
c.documents[documentKey(docs[0])].status='notApplicable';assert.ok(preparationBlockers(rows,docs,c).some(x=>x.includes('Yetki')));
});
test('changed requirement and changed product row require new checks',()=>{
assert.ok(preparationBlockers(rows,[{...docs[0],note:'Zeyilname 2'}],complete()).length>0);
assert.ok(preparationBlockers([{...rows[0],priceKey:'kit2'}],docs,complete()).length>0);
});