diff --git a/tests/unit/schema.pathology.test.ts b/tests/unit/schema.pathology.test.ts new file mode 100644 index 00000000..b928a221 --- /dev/null +++ b/tests/unit/schema.pathology.test.ts @@ -0,0 +1,37 @@ +import { describe, it, expect } from 'vitest' +import { PathologySchema } from '@/domain/schema/pathology' + +describe('PathologySchema', () => { + const base = { + id: 'desmite-suspenseur', + labelFr: 'Desmite du ligament suspenseur', + description: 'Inflammation du ligament suspenseur du boulet.', + category: 'tendino-ligamentaire' as const, + speciesIds: ['equine'], + boneIds: ['boulet-ant', 'boulet-post'], + sources: [ + { type: 'manual' as const, citation: 'Merck Vet Manual (2024).' }, + ], + } + + it('accepts a valid entry', () => { + expect(() => PathologySchema.parse(base)).not.toThrow() + }) + + it('rejects zero sources', () => { + expect(() => PathologySchema.parse({ ...base, sources: [] })).toThrow() + }) + + it('rejects empty id', () => { + expect(() => PathologySchema.parse({ ...base, id: '' })).toThrow() + }) + + it('rejects non-URL urls', () => { + expect(() => + PathologySchema.parse({ + ...base, + sources: [{ type: 'web', citation: 'X', url: 'not-a-url' }], + }), + ).toThrow() + }) +})