Add Vitest suites for relations, properties, catalogue, symbols, edge styles, flow solver, settings, JointJS shapes/serialization and the controller lifecycle (add/connect/edit/delete, undo-redo, copy-paste, flow, save-load). Introduce headless DiagramController (Paper-less) so the controller is testable outside a browser, and fix the flow direction sign. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
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: '' })
|
|
})
|
|
})
|