import { describe, it, expect } from 'vitest'; import { werkvoorraadRow, statusLabel, TYPE_LABELS } from './werkvoorraad-item-view'; import { WerkvoorraadItem } from './werkvoorraad-item'; const base: Omit = { id: '1', type: 'herregistratie', owner: '111222333', submittedAt: '2024-05-12', }; describe('werkvoorraadRow', () => { it('heading is the type, subtitle carries the owner BSN', () => { const row = werkvoorraadRow({ ...base, status: { tag: 'InBehandeling', referentie: 'R1', manual: false }, }); expect(row.heading).toBe(TYPE_LABELS.herregistratie); expect(row.subtitle).toContain('111222333'); }); it('status line carries the status label, reference and submit date', () => { const row = werkvoorraadRow({ ...base, status: { tag: 'InBehandeling', referentie: 'R1', manual: false }, }); 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 is called out distinctly from an automatic InBehandeling', () => { const manual = statusLabel({ tag: 'InBehandeling', referentie: 'R1', manual: true }); const auto = statusLabel({ tag: 'InBehandeling', referentie: 'R1', manual: false }); expect(manual).not.toBe(auto); }); it('a missing submit date leaves no dangling separator', () => { const row = werkvoorraadRow({ ...base, submittedAt: undefined, status: { tag: 'Ingediend', referentie: 'R9' }, }); expect(row.status).toBe(`${statusLabel({ tag: 'Ingediend', referentie: 'R9' })} ยท R9`); }); });