Files
faunosteo/tests/unit/species.equine.test.ts
T
ZenQuality b5b2e163c9 feat: domain core — schemas, store, equine data, PDF roundtrip
Phase A — Domain & schemas (15 tests):
- Zod schemas: ReportSchema, FindingSchema, PractitionerSchema, SeveritySchema
- Types derived via z.infer (single source of truth)
- newId() helper with optional prefix

Phase B — Equine anatomy + pathology DB (7 tests):
- 26 macro zones, axial subzones C1-7/T1-18/L1-6/S1-5
- 31 pathologies, each citing Merck Vet Manual, PubMed, IMAIOS or LCAO
- Placeholder SVGs (lateral L/R + dorsal) with data-zone convention
- Species registry: equine registered, 8 others remain stubs

Phase C — Zustand store (8 tests):
- Single source of truth with persist middleware (localStorage key osteo-report-draft)
- Actions: hydrate, reset, toggleZone, addFinding, updateFinding, removeFinding, setConclusion/Recommendations/NextAppointment

Phase H/I — PDF export + import roundtrip (2 tests):
- A4 portrait, pdf-lib StandardFonts
- Header (practitioner + animal), anatomy pages (per used view), findings
  table, conclusion/recommendations/RDV page, page footer with date+page#
- Attachment: base64 data URI workaround (pdf-lib treats raw string as
  base64 input, and rejects cross-realm Uint8Array in jsdom tests)
- Import: walks Catalog→Names→EmbeddedFiles→Names array→F stream; inflates
  via pako directly (bypasses pdf-lib's reference-equality FlateDecode check
  which fails across module realms in vitest); validates with ReportSchema

Tooling:
- Add pako 2.x + @types/pako (already transitive of pdf-lib)
- Switch vitest 2 → 3 (already done in prior commit)
- Add 8 test files (34 tests total green)
2026-05-17 07:06:59 +02:00

66 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { EQUINE_ANATOMY } from '@/species/equine/anatomy';
import { EQUINE_PATHOLOGIES } from '@/species/equine/pathologies';
describe('EQUINE_ANATOMY', () => {
it('has vertebral formula C7 / T18 / L6 / S5', () => {
expect(EQUINE_ANATOMY.vertebralFormula).toEqual({
cervical: 7,
thoracic: 18,
lumbar: 6,
sacral: 5,
});
});
it('declares the expected macro zones', () => {
const ids = EQUINE_ANATOMY.zones.map((z) => z.id);
for (const expected of [
'neck',
'withers',
'thoracic-back',
'lumbar',
'sacrum',
'shoulder-l',
'shoulder-r',
'hip-l',
'hip-r',
'tail',
]) {
expect(ids).toContain(expected);
}
});
it('thoracic-back has 18 subzones T1..T18', () => {
const z = EQUINE_ANATOMY.zones.find((zz) => zz.id === 'thoracic-back');
expect(z).toBeDefined();
expect(z?.subzones).toHaveLength(18);
expect(z?.subzones?.[0]?.id).toBe('T1');
expect(z?.subzones?.[17]?.id).toBe('T18');
});
it('every zone declares at least one view', () => {
for (const z of EQUINE_ANATOMY.zones) {
expect(z.views.length).toBeGreaterThan(0);
}
});
});
describe('EQUINE_PATHOLOGIES', () => {
it('seeds at least 30 entries', () => {
expect(EQUINE_PATHOLOGIES.length).toBeGreaterThanOrEqual(30);
});
it('every entry cites at least one source', () => {
for (const p of EQUINE_PATHOLOGIES) {
expect(p.sources.length).toBeGreaterThan(0);
}
});
it('every entry is applicable to equine', () => {
for (const p of EQUINE_PATHOLOGIES) {
expect(p.applicableSpecies).toContain('equine');
}
});
});