38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
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()
|
|
})
|
|
})
|