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>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { canConnectMedia, mediumColor, getColorScheme, MEDIUM_IDS, MEDIA } from '@diagram/relations'
|
|
|
|
describe('port relations', () => {
|
|
it('allows connecting identical media', () => {
|
|
for (const id of MEDIUM_IDS) expect(canConnectMedia(id, id)).toBe(true)
|
|
})
|
|
|
|
it('honors declared cross-compatibility symmetrically', () => {
|
|
expect(canConnectMedia('water', 'hotWater')).toBe(true)
|
|
expect(canConnectMedia('hotWater', 'water')).toBe(true)
|
|
expect(canConnectMedia('steam', 'hotWater')).toBe(true)
|
|
})
|
|
|
|
it('rejects incompatible media', () => {
|
|
expect(canConnectMedia('water', 'power')).toBe(false)
|
|
expect(canConnectMedia('gas', 'signal')).toBe(false)
|
|
expect(canConnectMedia('sewage', 'water')).toBe(false)
|
|
})
|
|
|
|
it('every medium declares its compatibility list', () => {
|
|
for (const id of MEDIUM_IDS) expect(Array.isArray(MEDIA[id].compatibleWith)).toBe(true)
|
|
})
|
|
|
|
it('resolves colors per scheme and falls back to default', () => {
|
|
expect(mediumColor('water', 'default')).toMatch(/^#/)
|
|
expect(mediumColor('water', 'colorblind')).not.toBe(mediumColor('water', 'default'))
|
|
expect(getColorScheme('does-not-exist').id).toBe('default')
|
|
})
|
|
})
|