|
1 | 1 | import { afterEach, describe, expect, it, vi } from 'vitest'; |
2 | 2 | import type { LJStateMachine, LJStateMachineErrorContext } from '../types/fsm'; |
3 | 3 | import { createMermaidDiagram, renderMermaidDiagram } from './diagram'; |
4 | | -import { getRelatedStates, getStateErrorFocus } from './diagram-focus'; |
| 4 | +import { getRelatedStates, getStateErrorFocus, getStateErrorFocuses, orderStateMachines } from './diagram-focus'; |
5 | 5 |
|
6 | 6 | // DefaultMutableTreeNode from the state error focus issue: |
7 | 7 | // root.add(...); root.removeAllChildren(); root.getFirstChild(); // state error |
@@ -250,3 +250,19 @@ describe('rendered state error focus', () => { |
250 | 250 | expect(dimmed('g.label.lj-dimmed')).toEqual(['edge0', 'edge1', 'edge12']); |
251 | 251 | }); |
252 | 252 | }); |
| 253 | + |
| 254 | +describe('state errors on several state sets', () => { |
| 255 | + const tiling: LJStateMachine = { ...treeNode(null), className: 'ImageWriteParam', stateSet: 0 }; |
| 256 | + const compression: LJStateMachine = { ...treeNode(), className: 'ImageWriteParam', stateSet: 1 }; |
| 257 | + const other: LJStateMachine = { ...treeNode(null), className: 'ImageWriteParam', stateSet: 2 }; |
| 258 | + |
| 259 | + it('puts the state sets with the error first, keeping the declaration order otherwise', () => { |
| 260 | + expect(orderStateMachines([tiling, compression, other])).toEqual([compression, tiling, other]); |
| 261 | + expect(orderStateMachines([tiling, other])).toEqual([tiling, other]); |
| 262 | + }); |
| 263 | + |
| 264 | + it('focuses on the error of each state set that has it', () => { |
| 265 | + expect(getStateErrorFocuses([tiling, compression, other])).toEqual([getStateErrorFocus(compression)]); |
| 266 | + expect(getStateErrorFocuses([tiling, other])).toEqual([]); |
| 267 | + }); |
| 268 | +}); |
0 commit comments