import { describe, it, expect } from 'vitest'; import { DuoLookupDto } from '@registratie/contracts/duo-diplomas.dto'; import { diplomaMsg } from './diploma-msg'; import { HANDMATIG } from './beroep.step'; const data: DuoLookupDto = { diplomas: [ { id: 'd1', naam: 'Verpleegkunde', instelling: 'Hogeschool Utrecht', jaar: 2019, beroep: 'Verpleegkundige', policyQuestions: [ { id: 'q1', vraag: 'Vraag 1', type: 'ja-nee' }, { id: 'q2', vraag: 'Vraag 2', type: 'tekst' }, ], }, ], handmatig: { beroepen: ['Verpleegkundige', 'Arts'], policyQuestions: [{ id: 'm1', vraag: 'Handmatige vraag', type: 'ja-nee' }], }, }; describe('diplomaMsg', () => { it('resolves a known diploma into KiesDiploma with the server-derived beroep', () => { expect(diplomaMsg(data, 'd1')).toEqual({ tag: 'KiesDiploma', diplomaId: 'd1', beroep: 'Verpleegkundige', vraagIds: ['q1', 'q2'], }); }); it('resolves the manual sentinel into KiesHandmatig with the maximal question set', () => { expect(diplomaMsg(data, HANDMATIG)).toEqual({ tag: 'KiesHandmatig', vraagIds: ['m1'] }); }); it('returns null for an unknown diploma id', () => { expect(diplomaMsg(data, 'onbekend')).toBeNull(); }); });