/** * V1-2.5: the new sheet's document comes from the core (contract ยง7.4), through the * page's runtime; the wrapper maps the input names and passes the closed refusal on. */ import { beforeAll, describe, expect, it } from 'vitest' import { setCoreRuntime } from '@/core/runtime' import { emptySheetDocument } from '@/core/sheetDocumentOps' import { testCoreRuntime } from '../helpers/core' const name = { fr: 'Nouvelle fiche', en: 'New sheet' } beforeAll(async () => { setCoreRuntime(await testCoreRuntime()) }) describe('emptySheetDocument', () => { it('answers the empty document of the species, named', () => { const outcome = emptySheetDocument({ speciesId: 'equine', name }) expect(outcome.ok).toBe(true) if (!outcome.ok) return expect(outcome.value.species_id).toBe('equine') expect(outcome.value.name).toEqual(name) expect(outcome.value.views.map((view) => view.id)).toEqual(['view-main']) }) it('refuses an invalid species id or an empty label', () => { for (const input of [ { speciesId: 'Not An Id', name }, { speciesId: 'equine', name: { fr: name.fr, en: '' } }, ]) { expect(emptySheetDocument(input)).toMatchObject({ ok: false, kind: 'invalid_shape', }) } }) })