36 lines
989 B
TypeScript
36 lines
989 B
TypeScript
import { describe, it, expect, beforeEach } from 'vitest'
|
|
import { useReportStore } from '@/state/reportStore'
|
|
|
|
const STORAGE_KEY = 'osteo:draft'
|
|
|
|
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()
|
|
sessionStorage.clear()
|
|
})
|
|
|
|
describe('reportStore sessionStorage mirror', () => {
|
|
it('mirrors the report on every change', () => {
|
|
useReportStore.getState().initReport(draft)
|
|
const raw = sessionStorage.getItem(STORAGE_KEY)
|
|
expect(raw).not.toBeNull()
|
|
const parsed = JSON.parse(raw!)
|
|
expect(parsed.practitioner.name).toBe('Dr. Dupont')
|
|
})
|
|
|
|
it('clears the mirror on reset', () => {
|
|
useReportStore.getState().initReport(draft)
|
|
useReportStore.getState().reset()
|
|
expect(sessionStorage.getItem(STORAGE_KEY)).toBeNull()
|
|
})
|
|
})
|