@@ -20,23 +20,24 @@ class MockNode implements Partial<LineageNode> {
2020 inEdges : MockEdge [ ]
2121 outEdges : MockEdge [ ]
2222
23- constructor ( id , [ prev , next ] : [ string | null , string | null ] ) {
23+ constructor ( id , prev : string [ ] , next : string [ ] ) {
2424 this . id = id
25- this . inEdges = prev ? [ new MockEdge ( prev , id ) ] : ( [ ] as MockEdge [ ] )
26- this . outEdges = next ? [ new MockEdge ( id , next ) ] : ( [ ] as MockEdge [ ] )
25+ this . inEdges = prev ? prev . map ( p => new MockEdge ( p , id ) ) : ( [ ] as MockEdge [ ] )
26+ this . outEdges = next ? next . map ( n => new MockEdge ( id , n ) ) : ( [ ] as MockEdge [ ] )
2727 }
2828}
2929
3030const mockGraphWithCycle = [
31- new MockNode ( '1' , [ '3' , '2' ] ) ,
32- new MockNode ( '2' , [ '1' , '3' ] ) ,
33- new MockNode ( '3' , [ '2' , '1' ] )
31+ new MockNode ( '1' , [ '3' ] , [ '2' ] ) ,
32+ new MockNode ( '2' , [ '1' ] , [ '3' ] ) ,
33+ new MockNode ( '3' , [ '2' ] , [ '1' ] )
3434] as LineageNode [ ]
3535
3636const mockGraphWithoutCycle = [
37- new MockNode ( '1' , [ null , '2' ] ) ,
38- new MockNode ( '2' , [ '1' , '3' ] ) ,
39- new MockNode ( '3' , [ '2' , null ] )
37+ new MockNode ( '1' , [ ] , [ '2' , '4' ] ) ,
38+ new MockNode ( '2' , [ '1' ] , [ '3' ] ) ,
39+ new MockNode ( '3' , [ '2' ] , [ ] ) ,
40+ new MockNode ( '4' , [ '1' ] , [ ] )
4041] as LineageNode [ ]
4142
4243describe ( 'Lineage Component' , ( ) => {
@@ -74,10 +75,27 @@ describe('Lineage Component', () => {
7475 const expectedPaths = [
7576 [ '1' , '2' ] ,
7677 [ '2' , '3' ] ,
77- [ '3' , '2' ] ,
78- [ '2' , '1' ]
78+ [ '3' , '1' ] ,
79+ [ '3' , '1' ] ,
80+ [ '2' , '3' ] ,
81+ [ '1' , '2' ]
7982 ]
8083
8184 expect ( actualPaths ) . toEqual ( expectedPaths )
8285 } )
86+
87+ it ( 'includes nodes in selected path when fullGraph is true' , ( ) => {
88+ const g = initGraph ( )
89+ buildGraphAll ( g , mockGraphWithoutCycle , true , '3' , ( ) => null )
90+
91+ expect ( g . node ( '4' ) ) . toBeDefined ( )
92+ } )
93+
94+ it ( 'exclude nodes not in selected path when fullGraph is false' , ( ) => {
95+ const g = initGraph ( )
96+
97+ buildGraphAll ( g , mockGraphWithoutCycle , false , '3' , ( ) => null )
98+
99+ expect ( g . node ( '4' ) ) . toBeUndefined ( )
100+ } )
83101} )
0 commit comments