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>
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { SYMBOLS, getSymbol, symbolDataUri, symbolsByCategory, SYMBOL_CATEGORIES } from '@diagram/symbols'
|
|
import { MEDIA } from '@diagram/relations'
|
|
import { schemaIndex } from '@diagram/properties'
|
|
|
|
describe('symbol registry', () => {
|
|
it('has unique ids', () => {
|
|
const ids = SYMBOLS.map((s) => s.id)
|
|
expect(new Set(ids).size).toBe(ids.length)
|
|
})
|
|
|
|
it('every port references a known medium and has fractional coords', () => {
|
|
for (const sym of SYMBOLS)
|
|
for (const p of sym.ports) {
|
|
expect(MEDIA[p.medium]).toBeDefined()
|
|
expect(p.x).toBeGreaterThanOrEqual(0)
|
|
expect(p.x).toBeLessThanOrEqual(1)
|
|
expect(p.y).toBeGreaterThanOrEqual(0)
|
|
expect(p.y).toBeLessThanOrEqual(1)
|
|
}
|
|
})
|
|
|
|
it('every symbol schema carries identity + presentation groups', () => {
|
|
for (const sym of SYMBOLS) {
|
|
const idx = schemaIndex(sym.schema)
|
|
expect(idx.has('title')).toBe(true)
|
|
expect(idx.has('color')).toBe(true)
|
|
expect(idx.has('rotation')).toBe(true)
|
|
}
|
|
})
|
|
|
|
it('recolors the icon in the data URI', () => {
|
|
const pump = getSymbol('pump')!
|
|
expect(symbolDataUri(pump)).toContain('data:image/svg')
|
|
expect(decodeURIComponent(symbolDataUri(pump, '#ff0000'))).toContain('#ff0000')
|
|
})
|
|
|
|
it('groups symbols by category', () => {
|
|
for (const cat of SYMBOL_CATEGORIES) expect(symbolsByCategory(cat).length).toBeGreaterThan(0)
|
|
})
|
|
})
|