/** * The core states, per view, the smallest radius a point may have (the sheet editor's size * slider marks it): the bundled draft's main view, from its frame and the preview size. */ import { beforeAll, describe, expect, it } from 'vitest' import { CataloguePreview } from '@/catalogue/preview' import { coreRuntime, setCoreRuntime } from '@/core/runtime' import { bundledSheet } from '../helpers/sheet' import { testCoreRuntime } from '../helpers/core' beforeAll(async () => { setCoreRuntime(await testCoreRuntime()) }) describe('min_point_radius of the preview state', () => { it('gives the bundled draft its main-view radius, none for an unknown view', async () => { const bundle = await bundledSheet() const [assetId] = Object.keys(bundle.assets) const preview = new CataloguePreview( coreRuntime(), { status: 'draft', document: JSON.stringify(bundle.document) }, [ { assetId, sha256: bundle.assetHashes[assetId], bytes: new TextEncoder().encode(bundle.assets[assetId]), }, ], ) const state = preview.state() if (!state.ok) throw new Error(state.kind) const radii = state.value.min_point_radius expect(radii['main']).toBeCloseTo(26.5, 1) expect(radii['nowhere'] ?? null).toBeNull() }) })