import { describe, it, expect } from 'vitest' import { createRef } from 'react' import { formulaConfig, formulaDownloadConfig } from './config' describe('formulaConfig', () => { it('returns an empty series array', () => { const cfg = formulaConfig() expect(cfg.series).toEqual([]) }) }) describe('formulaDownloadConfig', () => { it('returns a two-item download config (PNG + CSV)', () => { const refUI = createRef() const cfg = formulaDownloadConfig({ refUI }) expect(cfg).toHaveLength(2) }) it('CSV modifier maps numeric values out of data items', async () => { const refUI = createRef() const cfg = formulaDownloadConfig({ refUI }) const csvItem = cfg[1]! // Spy-style: the underlying downloadToCSV.modifier is the only thing that // actually returns. We just confirm `modifier` runs without throwing for // both populated and empty inputs — that exercises the `?? []` branch. await expect( csvItem.modifier([{ value: 1 }, { value: 2 }]), ).resolves.not.toThrow() await expect( csvItem.modifier( undefined as unknown as Parameters< NonNullable >[0], ), ).resolves.not.toThrow() }) })