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>
27 lines
944 B
TypeScript
27 lines
944 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { DEFAULT_SETTINGS, snap, routerConfig, connectorConfig } from '@diagram/settings'
|
|
|
|
describe('settings', () => {
|
|
it('snaps to grid when enabled', () => {
|
|
const s = { ...DEFAULT_SETTINGS, gridSize: 20, snapToGrid: true }
|
|
expect(snap(23, s)).toBe(20)
|
|
expect(snap(31, s)).toBe(40)
|
|
})
|
|
|
|
it('does not snap when disabled', () => {
|
|
const s = { ...DEFAULT_SETTINGS, snapToGrid: false }
|
|
expect(snap(23, s)).toBe(23)
|
|
})
|
|
|
|
it('uses a grid-aligned manhattan router', () => {
|
|
const r = routerConfig({ ...DEFAULT_SETTINGS, gridSize: 16 })
|
|
expect(r.name).toBe('manhattan')
|
|
expect(r.args.step).toBe(16)
|
|
})
|
|
|
|
it('switches connector between jumpover arc and rounded', () => {
|
|
expect(connectorConfig({ ...DEFAULT_SETTINGS, jumpover: true }).name).toBe('jumpover')
|
|
expect(connectorConfig({ ...DEFAULT_SETTINGS, jumpover: false }).name).toBe('rounded')
|
|
})
|
|
})
|