Files
faunosteo/docs/faunosteo-audit/relevant-files/tests/unit/schema.report.test.ts
T
bastien e471d41c6b docs(docs): add anatomical audit of existing SVG, catalog and report systems
Read-only technical audit before the SaaS redesign: 13 reports,
a logical anatomical-sheet JSON built from real horse data, verbatim
copies of the 52 relevant source files, and a self-contained ZIP.
2026-10-06 23:51:35 +02:00

54 lines
1.4 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { ReportSchema } from '@/domain/schema/report'
const minimal = {
version: 2 as const,
id: 'r1',
createdAt: '2026-05-18T10:00:00Z',
date: '2026-05-18',
practitioner: { name: 'Dr. Dupont' },
animal: { speciesId: 'equine', name: 'Mistral' },
owner: { name: 'Jean Martin' },
observations: [],
conclusion: '',
recommendations: '',
}
describe('ReportSchema', () => {
it('accepts a minimal valid report', () => {
expect(() => ReportSchema.parse(minimal)).not.toThrow()
})
it('accepts nextAppointment kind=date', () => {
expect(() =>
ReportSchema.parse({
...minimal,
nextAppointment: { kind: 'date', date: '2026-06-08' },
}),
).not.toThrow()
})
it('accepts nextAppointment kind=period', () => {
expect(() =>
ReportSchema.parse({
...minimal,
nextAppointment: { kind: 'period', text: 'dans 3 semaines' },
}),
).not.toThrow()
})
it('rejects legacy v1 reports', () => {
expect(() => ReportSchema.parse({ ...minimal, version: 1 })).toThrow()
})
it('rejects unknown future versions', () => {
expect(() => ReportSchema.parse({ ...minimal, version: 3 })).toThrow()
})
it('rejects empty practitioner.name', () => {
expect(() =>
ReportSchema.parse({ ...minimal, practitioner: { name: '' } }),
).toThrow()
})
})