import { describe, it, expect } from 'vitest' import { marker, dashArray, lineAttrs } from '@diagram/edges' describe('edge markers', () => { it('returns null for none', () => { expect(marker('none', '#000')).toBeNull() }) it('builds filled arrow and diamond paths', () => { expect(marker('arrow', '#f00')).toMatchObject({ type: 'path', fill: '#f00' }) expect(marker('diamond', '#f00')?.d).toContain('Z') }) it('builds a circle marker', () => { expect(marker('circle', '#0f0')).toMatchObject({ type: 'circle', r: 5 }) }) }) describe('dash patterns', () => { it('scales with stroke width', () => { expect(dashArray('solid', 3)).toBe('none') expect(dashArray('dashed', 2)).toBe('6 4') expect(dashArray('dotted', 2)).toBe('2 3') }) }) describe('line attrs', () => { it('composes stroke, dash and markers', () => { const attrs = lineAttrs({ color: '#123456', lineStyle: 'dashed', strokeWidth: 4, headMarker: 'arrow', tailMarker: 'none' }) expect(attrs.stroke).toBe('#123456') expect(attrs.strokeWidth).toBe(4) expect(attrs.strokeDasharray).toBe('12 8') expect(attrs.targetMarker).toMatchObject({ type: 'path' }) expect(attrs.sourceMarker).toEqual({ d: '' }) }) })