From 3ea8f522c0fdbea7bda3484904c4a1dd397f0b46 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Mon, 18 May 2026 21:42:15 +0200 Subject: [PATCH] test(species): pin pathology DB integrity contract (empty allowed in v1) --- tests/unit/species.equinePathologies.test.ts | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/unit/species.equinePathologies.test.ts diff --git a/tests/unit/species.equinePathologies.test.ts b/tests/unit/species.equinePathologies.test.ts new file mode 100644 index 00000000..6952bb74 --- /dev/null +++ b/tests/unit/species.equinePathologies.test.ts @@ -0,0 +1,39 @@ +import { describe, it, expect } from 'vitest' +import { PathologySchema } from '@/domain/schema/pathology' +import EQUINE_PATHOLOGIES from '@/domain/species/equine/pathologies' + +describe('equine pathologies database', () => { + it('has between 0 and 100 entries (empty allowed for v1)', () => { + expect(EQUINE_PATHOLOGIES.length).toBeGreaterThanOrEqual(0) + expect(EQUINE_PATHOLOGIES.length).toBeLessThanOrEqual(100) + }) + + it('every entry parses against the schema', () => { + for (const p of EQUINE_PATHOLOGIES) { + const r = PathologySchema.safeParse(p) + if (!r.success) throw new Error(`${p.id}: ${r.error.message}`) + } + }) + + it('every entry has at least one source', () => { + for (const p of EQUINE_PATHOLOGIES) { + expect(p.sources.length).toBeGreaterThanOrEqual(1) + } + }) + + it('every entry is tagged for equine when species-scoped', () => { + for (const p of EQUINE_PATHOLOGIES) { + if (p.speciesIds.length > 0) { + expect(p.speciesIds).toContain('equine') + } + } + }) + + it('every entry has a unique id', () => { + const ids = new Set() + for (const p of EQUINE_PATHOLOGIES) { + expect(ids.has(p.id)).toBe(false) + ids.add(p.id) + } + }) +})