@@ -4,7 +4,6 @@ import { Position } from '@xyflow/react'
44import {
55 getOnlySelectedNodes ,
66 getTransformedNodes ,
7- getTransformedModelEdges ,
87 getTransformedModelEdgesSourceTargets ,
98 getTransformedModelEdgesTargetSources ,
109 createNode ,
@@ -144,147 +143,6 @@ describe('Lineage Help Functions', () => {
144143 } )
145144 } )
146145
147- describe ( 'getTransformedModelEdges' , ( ) => {
148- test ( 'should transform edges using the provided transform function' , ( ) => {
149- const adjacencyListKeys = [ 'model1' , 'model2' , 'model3' ]
150- const lineageAdjacencyList : LineageAdjacencyList = {
151- model1 : [ 'model2' , 'model3' ] ,
152- model2 : [ 'model3' ] ,
153- model3 : [ ] ,
154- }
155-
156- const transformEdge = (
157- type : string ,
158- edgeId : EdgeId ,
159- sourceId : NodeId ,
160- targetId : NodeId ,
161- ) => ( {
162- id : edgeId ,
163- source : sourceId ,
164- target : targetId ,
165- type,
166- zIndex : 1 ,
167- } )
168-
169- const result = getTransformedModelEdges (
170- adjacencyListKeys ,
171- lineageAdjacencyList ,
172- transformEdge ,
173- )
174-
175- expect ( result ) . toHaveLength ( 3 )
176-
177- const model1Id = toNodeID ( 'model1' )
178- const model2Id = toNodeID ( 'model2' )
179- const model3Id = toNodeID ( 'model3' )
180-
181- expect ( result [ 0 ] ) . toEqual ( {
182- id : toEdgeID ( 'model1' , 'model2' ) ,
183- source : model1Id ,
184- target : model2Id ,
185- type : 'edge' ,
186- zIndex : 1 ,
187- } )
188- expect ( result [ 1 ] ) . toEqual ( {
189- id : toEdgeID ( 'model1' , 'model3' ) ,
190- source : model1Id ,
191- target : model3Id ,
192- type : 'edge' ,
193- zIndex : 1 ,
194- } )
195- expect ( result [ 2 ] ) . toEqual ( {
196- id : toEdgeID ( 'model2' , 'model3' ) ,
197- source : model2Id ,
198- target : model3Id ,
199- type : 'edge' ,
200- zIndex : 1 ,
201- } )
202- } )
203-
204- test ( 'should skip edges where target is not in adjacency list' , ( ) => {
205- const adjacencyListKeys = [ 'model1' ]
206- const lineageAdjacencyList : LineageAdjacencyList = {
207- model1 : [ 'model2' ] , // model2 is not in the adjacency list
208- }
209-
210- const transformEdge = (
211- type : string ,
212- edgeId : EdgeId ,
213- sourceId : NodeId ,
214- targetId : NodeId ,
215- ) => ( {
216- id : edgeId ,
217- source : sourceId ,
218- target : targetId ,
219- type,
220- zIndex : 1 ,
221- } )
222-
223- const result = getTransformedModelEdges (
224- adjacencyListKeys ,
225- lineageAdjacencyList ,
226- transformEdge ,
227- )
228-
229- expect ( result ) . toHaveLength ( 0 )
230- } )
231-
232- test ( 'should handle empty adjacency list' , ( ) => {
233- const adjacencyListKeys : string [ ] = [ ]
234- const lineageAdjacencyList : LineageAdjacencyList = { }
235-
236- const transformEdge = (
237- type : string ,
238- edgeId : EdgeId ,
239- sourceId : NodeId ,
240- targetId : NodeId ,
241- ) => ( {
242- id : edgeId ,
243- source : sourceId ,
244- target : targetId ,
245- type,
246- zIndex : 1 ,
247- } )
248-
249- const result = getTransformedModelEdges (
250- adjacencyListKeys ,
251- lineageAdjacencyList ,
252- transformEdge ,
253- )
254-
255- expect ( result ) . toHaveLength ( 0 )
256- } )
257-
258- test ( 'should handle nodes with no targets' , ( ) => {
259- const adjacencyListKeys = [ 'model1' , 'model2' ]
260- const lineageAdjacencyList = {
261- model1 : [ ] ,
262- model2 : null ,
263- } as unknown as LineageAdjacencyList
264-
265- const transformEdge = (
266- type : string ,
267- edgeId : EdgeId ,
268- sourceId : NodeId ,
269- targetId : NodeId ,
270- ) => ( {
271- id : edgeId ,
272- source : sourceId ,
273- target : targetId ,
274- type,
275- zIndex : 1 ,
276- } )
277-
278- const result = getTransformedModelEdges (
279- adjacencyListKeys ,
280- lineageAdjacencyList ,
281- transformEdge ,
282- )
283-
284- expect ( result ) . toHaveLength ( 0 )
285- } )
286- } )
287-
288146 describe ( 'getTransformedModelEdgesSourceTargets' , ( ) => {
289147 test ( 'should transform edges from source to targets using the provided transform function' , ( ) => {
290148 const adjacencyListKeys = [ 'model1' , 'model2' , 'model3' ]
0 commit comments