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>
26 lines
988 B
TypeScript
26 lines
988 B
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { CATALOGUES, getCatalogue, getCatalogueItem, seedsFromItem } from '@diagram/catalogue'
|
|
|
|
describe('catalogue', () => {
|
|
it('exposes catalogues by id', () => {
|
|
expect(getCatalogue('pipeMaterial')?.items.length).toBeGreaterThan(0)
|
|
expect(getCatalogue('missing')).toBeUndefined()
|
|
})
|
|
|
|
it('resolves items', () => {
|
|
expect(getCatalogueItem('pipeMaterial', 'pvc')?.label).toMatch(/PVC/)
|
|
expect(getCatalogueItem('pipeMaterial', 'nope')).toBeUndefined()
|
|
})
|
|
|
|
it('returns physics seeds for a chosen item', () => {
|
|
expect(seedsFromItem('pipeMaterial', 'steel')).toEqual({ roughness: 0.045 })
|
|
expect(seedsFromItem('pumpModel', 'grundfos-cr10')).toEqual({ flowRate: 10 })
|
|
expect(seedsFromItem('valveType', 'ball')).toEqual({})
|
|
})
|
|
|
|
it('every catalogue item has fields', () => {
|
|
for (const cat of Object.values(CATALOGUES))
|
|
for (const it of cat.items) expect(typeof it.fields).toBe('object')
|
|
})
|
|
})
|