Review company scan suggestions before saving profile
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user