import { describe, it, expect } from 'vitest'; import { submittedRow, detailRows, purposeLabel, statusLabel, TYPE_LABELS } from './aanvraag-view'; import { Aanvraag } from './aanvraag'; const base = { id: '1', type: 'herregistratie' as const, documentIds: [], createdAt: '', updatedAt: '', submittedAt: '2024-05-12' }; describe('submittedRow', () => { it('heading is the type, subtitle is the purpose', () => { const row = submittedRow({ ...base, status: { tag: 'InBehandeling', referentie: 'R1', manual: false } } as Aanvraag); expect(row.heading).toBe(TYPE_LABELS.herregistratie); expect(row.subtitle).toBe(purposeLabel('herregistratie')); }); it('status line carries the status label, reference and submit date', () => { const row = submittedRow({ ...base, status: { tag: 'InBehandeling', referentie: 'R1', manual: false } } as Aanvraag); expect(row.status).toContain(statusLabel({ tag: 'InBehandeling', referentie: 'R1', manual: false })); expect(row.status).toContain('R1'); expect(row.status).toContain('12 mei 2024'); }); it('manual review adds a note; rejection adds its reason', () => { const manual = submittedRow({ ...base, status: { tag: 'InBehandeling', referentie: 'R1', manual: true } } as Aanvraag); expect(manual.status).toContain('handmatig'); const rejected = submittedRow({ ...base, status: { tag: 'Afgewezen', referentie: 'R2', reden: 'Onvoldoende uren' } } as Aanvraag); expect(rejected.status).toContain('Onvoldoende uren'); }); }); describe('detailRows', () => { it('lists soort/waarvoor/status/referentie/ingediend, plus reason when rejected', () => { const rows = detailRows({ ...base, status: { tag: 'Afgewezen', referentie: 'R2', reden: 'Onvoldoende uren' } } as Aanvraag); const values = rows.map((r) => r.value); expect(values).toContain(TYPE_LABELS.herregistratie); expect(values).toContain('R2'); expect(values).toContain('Onvoldoende uren'); expect(rows.length).toBe(6); }); it('reference falls back to em dash for a Concept', () => { const rows = detailRows({ ...base, submittedAt: undefined, status: { tag: 'Concept', stepIndex: 0, stepCount: 3 } } as Aanvraag); const ref = rows.find((r) => r.value === '—'); expect(ref).toBeTruthy(); expect(rows.length).toBe(5); }); });