Files
faunosteo/tests/unit/anatomy.horse.test.ts
T

59 lines
1.9 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
import { parseSvgBones } from '@/anatomy/svgConvention'
const HERE = dirname(fileURLToPath(import.meta.url))
const HORSE_PATH = resolve(HERE, '../../public/species/equine/Horse.svg')
const HEAD_PATH = resolve(HERE, '../../public/species/equine/Horse_head.svg')
function loadSvg(path: string): SVGSVGElement {
const raw = readFileSync(path, 'utf8')
const doc = new DOMParser().parseFromString(raw, 'image/svg+xml')
return doc.documentElement as unknown as SVGSVGElement
}
describe('real Horse.svg', () => {
const map = parseSvgBones(loadSvg(HORSE_PATH))
it('parses without throwing', () => {
expect(map.size).toBeGreaterThan(10)
})
it('contains all 5 spine-zone bones', () => {
const spine = [...map.values()].filter((b) => b.category === 'spine-zone')
expect(spine.length).toBe(5)
})
it('contains the head zone with opensDetail=head', () => {
const head = [...map.values()].find((b) => b.category === 'head')
expect(head?.opensDetail).toBe('head')
})
it('contains the 3 vertebral hinges', () => {
const charn = [...map.values()].filter((b) => b.category === 'charniere')
expect(charn.map((b) => b.id).sort()).toEqual(['c7-t1', 'l6-s1', 't18-l1'])
})
it('contains main joint articulations', () => {
for (const id of ['epaule', 'coude', 'hanche', 'grasset', 'jarret']) {
expect(map.get(id)?.category).toBe('articulation')
}
})
})
describe('real Horse_head.svg', () => {
const map = parseSvgBones(loadSvg(HEAD_PATH))
it('parses without throwing', () => {
expect(map.size).toBeGreaterThan(5)
})
it('contains cadran-crane categories', () => {
const cadran = [...map.values()].filter((b) => b.category === 'cadran-crane')
expect(cadran.length).toBeGreaterThan(0)
})
})