test(schema): enforce >=1 source + url validation on Pathology

This commit is contained in:
Bastien Chanot committed 2026-05-18 21:00:19 +02:00
1 parent 839ddd05ff
commit 0556059ff6
1 file changed
+37
+37
View File
@@ -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()
})
})