import checkData from '../layout/dataChecker' ; const nodeIdErrorInput = { nodes : [ { data : { } , } , { id : null , data : { } , } , { id : undefined , data : { } , } , ] , edges : [ ] , } ; const nodeDataErrorInput = { nodes : [ { id : '1' , data : undefined , } , { id : '2' , data : null , } , { id : '3' , } , ] , edges : [ ] , } ; const nodeIdDupInput = { nodes : [ { id : '1' , data : { } , } , { id : '1' , data : { } , } , ] , edges : [ ] , } ; const edgeErrorInput = { nodes : [ ] , edges : [ { } , { source : null , data : { } } , { source : undefined , data : { } } , { source : '1' , data : { } } , { target : '2' , data : { } } , { target : null , data : { } } , { target : undefined , data : { } } , { source : '1' , target : '2' } , { source : '1' , target : '2' , data : null } , { source : '1' , target : '2' , data : undefined } , { source : null , target : null } , { source : undefined , target : undefined } , ] , } ; const edgeDupInput = { nodes : [ ] , edges : [ { source : '1' , target : '2' , data : { } } , { source : '1' , target : '2' , data : { } } , ] , } ; const noopInput = { } ; const CheckerOption = { edge : { autoLoop : true , autoPoly : false , } , } ; describe ( 'DataChecking' , ( ) => { it ( 'should skip node when node id is missing or null' , ( ) => { expect ( checkData ( nodeIdErrorInput , CheckerOption ) . nodes . length ) . toBe ( 0 ) ; } ) ; it ( 'should skip node when node data is missing or null' , ( ) => { expect ( checkData ( nodeDataErrorInput , CheckerOption ) . nodes . length ) . toBe ( 0 ) ; } ) ; it ( 'should skip node when node id is duplicated' , ( ) => { expect ( checkData ( nodeIdDupInput , CheckerOption ) . nodes . length ) . toBe ( 1 ) ; } ) ; it ( 'should skip edge when source/target/data is missing or null' , ( ) => { expect ( checkData ( edgeErrorInput , CheckerOption ) . edges . length ) . toBe ( 0 ) ; } ) ; it ( 'should reserve edge when source/target is duplicated' , ( ) => { expect ( checkData ( edgeDupInput , CheckerOption ) . edges . length ) . toBe ( 2 ) ; } ) ; it ( 'should return empty result when input noop' , ( ) => { expect ( checkData ( noopInput , CheckerOption ) . edges . length ) . toBe ( 0 ) ; expect ( checkData ( noopInput , CheckerOption ) . nodes . length ) . toBe ( 0 ) ; expect ( checkData ( undefined , CheckerOption ) . nodes . length ) . toBe ( 0 ) ; expect ( checkData ( undefined , CheckerOption ) . edges . length ) . toBe ( 0 ) ; } ) ; } ) ;