Files
faunosteo/apps/app/tests/unit/state.reportStore.setters.test.ts
T
bchanot 8673475293 chore(workspace): move the app to apps/app under a pnpm workspace (step 2)
144 files moved with git mv (pure renames). Root package.json delegates
dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and
pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager,
root devDependency, engine-strict). Dockerfile builds @faunosteo/app on
node:24-alpine and copies apps/app/dist; nginx and runtime config
unchanged. CI workflow for Gitea Actions. packages/ reserved (README only).
Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan.
271/271 tests, typecheck, lint, build green from the root.
2026-10-08 21:51:13 +02:00

57 lines
1.8 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 identity setters', () => {
it('setPractitioner replaces the practitioner block', () => {
useReportStore.getState().initReport(draft)
useReportStore.getState().setPractitioner({
name: 'Dr. Curie',
cabinet: 'Clinique du Pré',
contact: 'contact@example.test',
})
const p = useReportStore.getState().report!.practitioner
expect(p.name).toBe('Dr. Curie')
expect(p.cabinet).toBe('Clinique du Pré')
expect(p.contact).toBe('contact@example.test')
})
it('setAnimal replaces the animal block', () => {
useReportStore.getState().initReport(draft)
useReportStore.getState().setAnimal({
speciesId: 'equine',
name: 'Tempête',
breed: 'Pur-sang',
})
const a = useReportStore.getState().report!.animal
expect(a.name).toBe('Tempête')
expect(a.breed).toBe('Pur-sang')
})
it('setOwner replaces the owner block', () => {
useReportStore.getState().initReport(draft)
useReportStore.getState().setOwner({ name: 'Marie Petit' })
expect(useReportStore.getState().report!.owner.name).toBe('Marie Petit')
})
it('setters are no-ops when no report is loaded', () => {
useReportStore.getState().setPractitioner({ name: 'Ghost' })
useReportStore.getState().setAnimal({ speciesId: 'equine', name: 'Ghost' })
useReportStore.getState().setOwner({ name: 'Ghost' })
expect(useReportStore.getState().report).toBeNull()
})
})