import { describe, it, expect } from 'vitest' import { addBrush } from './transforms' describe('addBrush', () => { it('adds a brush block with rect/clear toolbox', () => { const out = addBrush({}) as { brush: { toolbox: string[]; xAxisIndex: string } } expect(out.brush.toolbox).toEqual(['rect', 'clear']) expect(out.brush.xAxisIndex).toBe('all') }) it('configures outOfBrush dim alpha at 0.15 (matches v1)', () => { const out = addBrush({}) as { brush: { outOfBrush: { colorAlpha: number } } } expect(out.brush.outOfBrush.colorAlpha).toBe(0.15) }) it('adds the toolbox.feature.brush so the user gets the brush UI', () => { const out = addBrush({}) as { toolbox: { feature: { brush: { type: string[] } } } } expect(out.toolbox.feature.brush.type).toEqual(['rect', 'clear']) }) it('preserves an existing toolbox config and adds the brush feature on top', () => { const seeded = { toolbox: { right: 8, feature: { saveAsImage: {} } }, } const out = addBrush(seeded) as { toolbox: { right: number feature: { saveAsImage: object; brush: object } } } expect(out.toolbox.right).toBe(8) expect(out.toolbox.feature.saveAsImage).toEqual({}) expect(out.toolbox.feature.brush).toBeDefined() }) it('returns the input unchanged when not an object', () => { expect(addBrush(null)).toBe(null) expect(addBrush(undefined)).toBe(undefined) expect(addBrush(42)).toBe(42) }) })