|
1 | | -import { it, describe, expect, vi } from 'vitest'; |
| 1 | +import { it, describe, expect, vi, beforeEach, afterEach } from 'vitest'; |
2 | 2 | import cytoscape from 'cytoscape'; |
3 | 3 | import { parser } from './architectureParser.js'; |
4 | 4 | import { ArchitectureDB } from './architectureDb.js'; |
| 5 | +import { setConfig, reset as resetConfig } from '../../config.js'; |
5 | 6 | describe('architecture diagrams', () => { |
6 | 7 | let db: ArchitectureDB; |
7 | 8 | beforeEach(() => { |
@@ -158,6 +159,42 @@ describe('architecture diagrams', () => { |
158 | 159 | }); |
159 | 160 | }); |
160 | 161 |
|
| 162 | + describe('fcose layout config', () => { |
| 163 | + afterEach(() => { |
| 164 | + resetConfig(); |
| 165 | + }); |
| 166 | + |
| 167 | + it('should default the fcose knobs to documented values', () => { |
| 168 | + expect(db.getConfigField('nodeSeparation')).toBe(75); |
| 169 | + expect(db.getConfigField('idealEdgeLengthMultiplier')).toBe(1.5); |
| 170 | + expect(db.getConfigField('edgeElasticity')).toBe(0.45); |
| 171 | + expect(db.getConfigField('numIter')).toBe(2500); |
| 172 | + }); |
| 173 | + |
| 174 | + it('should round-trip user-supplied fcose knobs', () => { |
| 175 | + setConfig({ |
| 176 | + architecture: { |
| 177 | + nodeSeparation: 120, |
| 178 | + idealEdgeLengthMultiplier: 2, |
| 179 | + edgeElasticity: 0.6, |
| 180 | + numIter: 5000, |
| 181 | + }, |
| 182 | + }); |
| 183 | + expect(db.getConfigField('nodeSeparation')).toBe(120); |
| 184 | + expect(db.getConfigField('idealEdgeLengthMultiplier')).toBe(2); |
| 185 | + expect(db.getConfigField('edgeElasticity')).toBe(0.6); |
| 186 | + expect(db.getConfigField('numIter')).toBe(5000); |
| 187 | + }); |
| 188 | + |
| 189 | + it('should leave defaults intact when only one knob is set', () => { |
| 190 | + setConfig({ architecture: { nodeSeparation: 200 } }); |
| 191 | + expect(db.getConfigField('nodeSeparation')).toBe(200); |
| 192 | + expect(db.getConfigField('idealEdgeLengthMultiplier')).toBe(1.5); |
| 193 | + expect(db.getConfigField('edgeElasticity')).toBe(0.45); |
| 194 | + expect(db.getConfigField('numIter')).toBe(2500); |
| 195 | + }); |
| 196 | + }); |
| 197 | + |
161 | 198 | describe('addJunction validation', () => { |
162 | 199 | it('should throw if junction id is already in use by a service', () => { |
163 | 200 | db.addGroup({ id: 'g1', title: 'Group' }); |
|
0 commit comments