One-time prettier --write so the new format:check CI gate starts green. .prettierignore excludes generated (api-client.ts, documentation.json), vendored (public/cibg-huisstijl), and backend (dotnet format owns it). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { parseDashboardView } from './dashboard-view.adapter';
|
|
|
|
const valid = {
|
|
registration: {
|
|
bigNummer: '19012345601',
|
|
naam: 'Dr. A. de Vries',
|
|
beroep: 'Arts',
|
|
registratiedatum: '2012-09-01',
|
|
geboortedatum: '1985-03-14',
|
|
status: { tag: 'Geregistreerd', herregistratieDatum: '2027-03-01' },
|
|
},
|
|
person: {
|
|
naam: 'Dr. A. de Vries',
|
|
geboortedatum: '1985-03-14',
|
|
adres: { straat: 'X 1', postcode: '2514 EA', woonplaats: 'Den Haag' },
|
|
},
|
|
decisions: { eligibleForHerregistratie: true, herregistratieReason: 'within window' },
|
|
};
|
|
|
|
describe('parseDashboardView (trust boundary)', () => {
|
|
it('maps a valid response into a DashboardView', () => {
|
|
const r = parseDashboardView(valid);
|
|
expect(r.ok).toBe(true);
|
|
if (r.ok) {
|
|
expect(r.value.profile.registration.bigNummer).toBe('19012345601');
|
|
expect(r.value.decisions.eligibleForHerregistratie).toBe(true);
|
|
}
|
|
});
|
|
|
|
it('rejects malformed responses instead of trusting them', () => {
|
|
expect(parseDashboardView(null).ok).toBe(false);
|
|
expect(parseDashboardView({ ...valid, registration: undefined }).ok).toBe(false);
|
|
expect(
|
|
parseDashboardView({ ...valid, decisions: { eligibleForHerregistratie: 'yes' } }).ok,
|
|
).toBe(false);
|
|
});
|
|
});
|