@@ -443,7 +443,49 @@ describe('findStartNodes', () => {
443
443
expect ( startNodes ) . toContainEqual ( node2 ) ;
444
444
} ) ;
445
445
446
+ describe ( 'pinData' , ( ) => {
447
+ // PD ►►
448
+ // ┌───────┐1 ┌──────────┐0 ┌───────────┐
449
+ // │trigger├────►pinnedNode├────►destination│
450
+ // └───────┘ └──────────┘ └───────────┘
451
+ test ( 'does not stop recursing when the first node that has no run data has pinned data' , ( ) => {
452
+ // ARRANGE
453
+ const trigger = createNodeData ( { name : 'trigger' } ) ;
454
+ const pinnedNode = createNodeData ( { name : 'pinnedNode' } ) ;
455
+ const destination = createNodeData ( { name : 'destinationNode' } ) ;
456
+ const graph = new DirectedGraph ( )
457
+ . addNodes ( trigger , destination , pinnedNode )
458
+ . addConnections ( { from : trigger , to : pinnedNode } , { from : pinnedNode , to : destination } ) ;
459
+ const pinData : IPinData = { [ pinnedNode . name ] : [ { json : { value : 1 } } ] } ;
460
+ const runData : IRunData = {
461
+ [ trigger . name ] : [ toITaskData ( [ { data : { value : 1 } } ] ) ] ,
462
+ } ;
463
+
464
+ // ACT
465
+ const startNodes = findStartNodes ( {
466
+ graph,
467
+ trigger,
468
+ destination,
469
+ runData,
470
+ pinData,
471
+ } ) ;
472
+
473
+ // ASSERT
474
+ expect ( startNodes . size ) . toBe ( 1 ) ;
475
+ expect ( startNodes ) . toContain ( destination ) ;
476
+ } ) ;
477
+ } ) ;
478
+
446
479
describe ( 'custom loop logic' , ( ) => {
480
+ // ►►
481
+ // ┌────┐0 ┌─────────┐
482
+ // ┌───────┐1 │ ├───►afterLoop│
483
+ // │trigger├─┬─►loop│1 └─────────┘
484
+ // └───────┘ │ │ ├─┐ ┌──────┐1
485
+ // │ └────┘ └─►inLoop├──┐
486
+ // │ └──────┘ │
487
+ // └────────────────────┘
488
+ //
447
489
test ( 'if the last run of loop node has no data (null) on the done output, then the loop is the start node' , ( ) => {
448
490
// ARRANGE
449
491
const trigger = createNodeData ( { name : 'trigger' } ) ;
@@ -482,6 +524,15 @@ describe('findStartNodes', () => {
482
524
expect ( startNodes ) . toContainEqual ( loop ) ;
483
525
} ) ;
484
526
527
+ // ►►
528
+ // ┌────┐0 ┌─────────┐
529
+ // ┌───────┐1 │ ├───►afterLoop│
530
+ // │trigger├─┬─►loop│1 └─────────┘
531
+ // └───────┘ │ │ ├─┐ ┌──────┐1
532
+ // │ └────┘ └─►inLoop├──┐
533
+ // │ └──────┘ │
534
+ // └────────────────────┘
535
+ //
485
536
test ( 'if the last run of loop node has no data (empty array) on the done output, then the loop is the start node' , ( ) => {
486
537
// ARRANGE
487
538
const trigger = createNodeData ( { name : 'trigger' } ) ;
@@ -527,6 +578,15 @@ describe('findStartNodes', () => {
527
578
expect ( startNodes ) . toContainEqual ( loop ) ;
528
579
} ) ;
529
580
581
+ // ►►
582
+ // ┌────┐1 ┌─────────┐
583
+ // ┌───────┐1 │ ├───►afterLoop│
584
+ // │trigger├─┬─►loop│1 └─────────┘
585
+ // └───────┘ │ │ ├─┐ ┌──────┐1
586
+ // │ └────┘ └─►inLoop├──┐
587
+ // │ └──────┘ │
588
+ // └────────────────────┘
589
+ //
530
590
test ( 'if the loop has data on the done output in the last run it does not become a start node' , ( ) => {
531
591
// ARRANGE
532
592
const trigger = createNodeData ( { name : 'trigger' } ) ;
0 commit comments