Build interactive system landscape simulator
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { demoLandscape, validateLandscape } from './model'
|
||||
|
||||
describe('landscape model', () => {
|
||||
it('provides the editable demo landscape', () => {
|
||||
const landscape = demoLandscape()
|
||||
expect(landscape.systems).toHaveLength(5)
|
||||
expect(landscape.scenarios.map((scenario) => scenario.name)).toEqual(['Place order', 'Register customer'])
|
||||
expect(landscape.scenarios[0].steps[2].connectionIds).toHaveLength(2)
|
||||
})
|
||||
it('round-trips a valid landscape and preserves positions', () => {
|
||||
const source = demoLandscape(); const imported = validateLandscape(JSON.parse(JSON.stringify(source)))
|
||||
expect(imported).toEqual(source); expect(imported.systems.find((system) => system.id === 'website')?.position).toEqual([80, 180])
|
||||
})
|
||||
it('rejects connections that reference deleted systems', () => { const source = demoLandscape(); source.connections[0].targetId = 'deleted-system'; expect(() => validateLandscape(source)).toThrow(/missing system/) })
|
||||
it('rejects scenario steps that reference deleted connections', () => { const source = demoLandscape(); source.scenarios[0].steps[0].connectionIds = ['deleted-connection']; expect(() => validateLandscape(source)).toThrow(/deleted connection/) })
|
||||
it('rejects unsupported or malformed imports', () => { expect(() => validateLandscape(null)).toThrow(/JSON object/); expect(() => validateLandscape({ version: 2 })).toThrow(/Unsupported landscape format/) })
|
||||
})
|
||||
Reference in New Issue
Block a user