Files
faunosteo/tests/unit/state.reportStore.test.ts
T

41 lines
1.2 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest'
import { useReportStore } from '@/state/reportStore'
const draft = {
date: '2026-05-18',
practitioner: { name: 'Dr. Dupont' },
animal: { speciesId: 'equine', name: 'Mistral' },
owner: { name: 'Jean Martin' },
observations: [],
conclusion: '',
recommendations: '',
}
beforeEach(() => {
useReportStore.getState().reset()
})
describe('reportStore.initReport', () => {
it('sets a report with version=1, id, and createdAt', () => {
useReportStore.getState().initReport(draft)
const r = useReportStore.getState().report!
expect(r.version).toBe(1)
expect(r.id.length).toBeGreaterThan(0)
expect(r.createdAt).toMatch(/^\d{4}-\d{2}-\d{2}T/)
expect(r.practitioner.name).toBe('Dr. Dupont')
})
it('resets activeObservationIndex to 0', () => {
useReportStore.getState().initReport(draft)
expect(useReportStore.getState().activeObservationIndex).toBe(0)
})
})
describe('reportStore.reset', () => {
it('clears the report', () => {
useReportStore.getState().initReport(draft)
useReportStore.getState().reset()
expect(useReportStore.getState().report).toBeNull()
})
})