@@ -4,6 +4,7 @@ import { StateDB } from './stateDb.js';
4
4
describe ( 'state diagram V2, ' , function ( ) {
5
5
// TODO - these examples should be put into ./parser/stateDiagram.spec.js
6
6
describe ( 'when parsing an info graph it' , function ( ) {
7
+ /** @type {StateDB } */
7
8
let stateDb ;
8
9
beforeEach ( function ( ) {
9
10
stateDb = new StateDB ( 2 ) ;
@@ -346,6 +347,20 @@ describe('state diagram V2, ', function () {
346
347
` ;
347
348
348
349
parser . parse ( str ) ;
350
+ expect ( stateDb . getState ( 'Active' ) . note ) . toMatchInlineSnapshot ( `
351
+ {
352
+ "position": "left of",
353
+ "text": "this is a short<br>note",
354
+ }
355
+ ` ) ;
356
+ expect ( stateDb . getState ( 'Inactive' ) . note ) . toMatchInlineSnapshot ( `
357
+ {
358
+ "position": "right of",
359
+ "text": "A note can also
360
+ be defined on
361
+ several lines",
362
+ }
363
+ ` ) ;
349
364
} ) ;
350
365
it ( 'should handle multiline notes with different line breaks' , function ( ) {
351
366
const str = `stateDiagram-v2
@@ -356,6 +371,12 @@ describe('state diagram V2, ', function () {
356
371
` ;
357
372
358
373
parser . parse ( str ) ;
374
+ expect ( stateDb . getStates ( ) . get ( 'State1' ) . note ) . toMatchInlineSnapshot ( `
375
+ {
376
+ "position": "right of",
377
+ "text": "Line1<br>Line2<br>Line3<br>Line4<br>Line5",
378
+ }
379
+ ` ) ;
359
380
} ) ;
360
381
it ( 'should handle floating notes' , function ( ) {
361
382
const str = `stateDiagram-v2
@@ -366,15 +387,14 @@ describe('state diagram V2, ', function () {
366
387
parser . parse ( str ) ;
367
388
} ) ;
368
389
it ( 'should handle floating notes' , function ( ) {
369
- const str = `stateDiagram-v2\n
390
+ const str = `stateDiagram-v2
370
391
state foo
371
392
note "This is a floating note" as N1
372
393
` ;
373
-
374
394
parser . parse ( str ) ;
375
395
} ) ;
376
396
it ( 'should handle notes for composite (nested) states' , function ( ) {
377
- const str = `stateDiagram-v2\n
397
+ const str = `stateDiagram-v2
378
398
[*] --> NotShooting
379
399
380
400
state "Not Shooting State" as NotShooting {
@@ -389,6 +409,12 @@ describe('state diagram V2, ', function () {
389
409
` ;
390
410
391
411
parser . parse ( str ) ;
412
+ expect ( stateDb . getState ( 'NotShooting' ) . note ) . toMatchInlineSnapshot ( `
413
+ {
414
+ "position": "right of",
415
+ "text": "This is a note on a composite state",
416
+ }
417
+ ` ) ;
392
418
} ) ;
393
419
394
420
it ( 'A composite state should be able to link to itself' , ( ) => {
0 commit comments