import { describe, expect, it } from 'vitest'; import { collectSvgCounts } from './svgCounts.ts'; describe('collectSvgCounts', () => { it('returns null for invalid XML', () => { expect(collectSvgCounts('not xml <<<<')).toBeNull(); }); it('returns null for non-SVG XML', () => { expect(collectSvgCounts('')).toBeNull(); expect(collectSvgCounts('
')).toBeNull(); }); it('counts the root svg element as a container', () => { const counts = collectSvgCounts(''); expect(counts).not.toBeNull(); expect(counts!.get('container')).toBe(1); expect(counts!.size).toBe(1); }); it('counts element kinds', () => { const counts = collectSvgCounts('')!; expect(counts.get('geometry')).toBe(2); expect(counts.get('text')).toBe(1); }); it('counts container elements including the root svg', () => { const counts = collectSvgCounts('')!; expect(counts.get('container')).toBe(2); expect(counts.get('geometry')).toBe(1); }); it('counts use and image elements', () => { const counts = collectSvgCounts( '', )!; expect(counts.get('use')).toBe(1); expect(counts.get('image')).toBe(1); }); it('walks nested elements', () => { const counts = collectSvgCounts( '', )!; expect(counts.get('geometry')).toBe(2); expect(counts.get('container')).toBe(3); }); });