feat(schema): add LateralSideSchema and Bone.lateral for laterality support
Exports LateralSideSchema (z.enum left/right) and LateralSide type. Adds optional side field to ObservationZoneSchema for bilateral zone distinction. Covers new schema with 6 dedicated tests (accepts/rejects for both types). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
db50c67bb6
commit
e0abb1efa1
2 files changed
+49
No files matched your search
@@ -4,6 +4,8 @@ import {
|
||||
VertebraSchema,
|
||||
SeveritySchema,
|
||||
FindingSchema,
|
||||
LateralSideSchema,
|
||||
ObservationZoneSchema,
|
||||
} from '@/domain/schema/observation'
|
||||
|
||||
describe('SeveritySchema', () => {
|
||||
@@ -62,6 +64,48 @@ describe('FindingSchema', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('LateralSideSchema', () => {
|
||||
it('accepts left and right', () => {
|
||||
expect(LateralSideSchema.parse('left')).toBe('left')
|
||||
expect(LateralSideSchema.parse('right')).toBe('right')
|
||||
})
|
||||
|
||||
it('rejects unknown side', () => {
|
||||
expect(() => LateralSideSchema.parse('both')).toThrow()
|
||||
expect(() => LateralSideSchema.parse('')).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ObservationZoneSchema with side', () => {
|
||||
it('accepts a zone without side (unpaired)', () => {
|
||||
expect(() => ObservationZoneSchema.parse({ boneId: 'sternum' })).not.toThrow()
|
||||
})
|
||||
|
||||
it('accepts a zone with side left', () => {
|
||||
const parsed = ObservationZoneSchema.parse({ boneId: 'knee', side: 'left' })
|
||||
expect(parsed.side).toBe('left')
|
||||
})
|
||||
|
||||
it('accepts a zone with side right', () => {
|
||||
const parsed = ObservationZoneSchema.parse({ boneId: 'knee', side: 'right' })
|
||||
expect(parsed.side).toBe('right')
|
||||
})
|
||||
|
||||
it('accepts two zones with same boneId but different sides', () => {
|
||||
const obs = {
|
||||
id: 'obs-1',
|
||||
zones: [
|
||||
{ boneId: 'knee', side: 'left' },
|
||||
{ boneId: 'knee', side: 'right' },
|
||||
],
|
||||
findings: [],
|
||||
freeTextFindings: [],
|
||||
comment: '',
|
||||
}
|
||||
expect(() => ObservationSchema.parse(obs)).not.toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('ObservationSchema', () => {
|
||||
const baseObs = {
|
||||
id: 'obs-1',
|
||||
|
||||
Reference in new issue
Block a user