Files
ihaleist/tests/company-profile.test.mjs
T

14 lines
1.1 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 {scanCompanyProposal,companyScanProposal} from '../src/services/companyProfile.js';
test('failed company scan throws instead of fabricating domain-derived products',async()=>{
await assert.rejects(scanCompanyProposal('https://lab-medical.example',{request:async()=>{throw new Error('Provider unavailable');}}),/Provider unavailable/);
for(const sonuc of [{},{urunler:'kit'},{sektorler:[],urunler:[{}],sertifikalar:[],ihaleKonulari:[]}])assert.throws(()=>companyScanProposal({sonuc}));
});
test('successful scan is returned as editable source suggestions with no profile write request',async()=>{
const calls=[];const result=await scanCompanyProposal('https://example.test',{request:async(url,options)=>{calls.push({url,options});return {sonuc:{sektorler:[' Sağlık ','Sağlık'],urunler:['Kit'],sertifikalar:[],ihaleKonulari:['Laboratuvar']},tarananSayfa:2};}});
assert.equal(calls.length,1);assert.equal(calls[0].url,'/api/company/scan');
assert.deepEqual(result.extractedSectors,['Sağlık']);assert.deepEqual(result.extractedProducts,['Kit']);
assert.equal(result.gercekTarama,true);
});