import { describe, expect, it } from 'vitest' import { normalizeImageVectorizeOptions, toVTracerOptions, vectorizePng } from './imageVectorizationService' describe('image vectorization options', () => { it('maps the poster preset to seam-free spline tracing', () => { const options = normalizeImageVectorizeOptions({ preset: 'poster', colorCount: 16, detail: 'medium', filterSpeckle: 8 }) expect(toVTracerOptions(options)).toMatchObject({ preset: 'poster', clustering: 'color-cluster', hierarchical: 'cutout', mode: 'spline', maxColors: 16, simplify: 1.25, optimize: 2 }) }) it('does not apply a color count in black-and-white mode', () => { const options = normalizeImageVectorizeOptions({ preset: 'bw', colorCount: 16, detail: 'high', filterSpeckle: 0 }) expect(toVTracerOptions(options)).toMatchObject({ preset: 'bw', clustering: 'bw', maxColors: undefined, simplify: 0.5 }) }) it('rejects parameters outside the supported limits', () => { expect(() => normalizeImageVectorizeOptions({ preset: 'poster', colorCount: 1, detail: 'medium', filterSpeckle: 8 })).toThrow('color count') expect(() => normalizeImageVectorizeOptions({ preset: 'poster', colorCount: 16, detail: 'ultra', filterSpeckle: 8 })).toThrow('options') }) it('produces real SVG paths without embedding the source bitmap', () => { const options = normalizeImageVectorizeOptions({ preset: 'poster', colorCount: 4, detail: 'medium', filterSpeckle: 0 }) const svg = vectorizePng(sampleBmp(), options) expect(svg).toContain('