import { bomAgent, BomAgentResult } from '../src/services/qualimetrie/bomAgent'; // Mock license-checker.init to callback with test data jest.mock('license-checker', () => ({ init: (_opts: any, cb: Function) => { const data = { 'packageA@1.0.0': { licenses: 'MIT' }, 'packageB@2.0.0': { licenses: ['GPL', 'Apache-2.0'] }, 'packageC@3.0.0': { licenses: null }, }; cb(null, data); }, })); describe('bomAgent', () => { it('should list packages with correct risk evaluation', async () => { const res: BomAgentResult = await bomAgent(); expect(res.packages).toHaveLength(3); const pkgA = res.packages.find(p => p.name === 'packageA'); expect(pkgA).toMatchObject({ version: '1.0.0', license: 'MIT', risk: 'Low' }); const pkgB = res.packages.find(p => p.name === 'packageB'); // GPL strong copyleft yields 'High'; Apache yields 'Low', but combined string still 'High' due to initial 'gpl' expect(pkgB?.risk).toBe('High'); }); });