import { GraphNode } from '../../../../algorithms/graph-algorithms/graph' ; import { addNode , deleteNode , initGraph , changeDestinationNode , changeSourceNode , } from '../../../../store/graph/actions' ; import { ADD_NODE , CHANGE_DESTINATION_NODE , CHANGE_SOURCE_NODE , DELETE_NODE , GraphActionTypes , INIT_GRAPH , } from '../../../../store/graph/types' ; import { TableNodeType } from '../../../../utils/types/graph-types/table-node-type' ; describe ( 'graph actions' , ( ) => { it ( 'should create an action to add a node' , ( ) => { const node = { id : '0' } as GraphNode ; const table = [ [ ] ] ; const addNodeAction = { type : ADD_NODE , node : node , table : table , } ; expect ( addNode ( node , table ) ) . toEqual ( addNodeAction ) ; } ) ; it ( 'should create an action to delete a node' , ( ) => { const node = { id : '0' } as GraphNode ; const deleteNodeAction = { type : DELETE_NODE , node : node , } ; expect ( deleteNode ( node ) ) . toEqual ( deleteNodeAction ) ; } ) ; it ( 'should create an action to initialize the graph' , ( ) => { const width = 0 ; const height = 0 ; const initGraphAction = { type : INIT_GRAPH , height : height , width : width , } ; expect ( initGraph ( height , width ) ) . toEqual ( initGraphAction ) ; } ) ; it ( 'should create an action to change source node' , ( ) => { const newSource = { id : '0' } as GraphNode ; const changeSourceAction = { type : CHANGE_SOURCE_NODE , newSource : newSource , } ; expect ( changeSourceNode ( newSource ) ) . toEqual ( changeSourceAction ) ; } ) ; it ( 'should create an action to change destination node' , ( ) => { const newDest = { id : '0' } as GraphNode ; const changeDestAction = { type : CHANGE_DESTINATION_NODE , newDest : newDest , } ; expect ( changeDestinationNode ( newDest ) ) . toEqual ( changeDestAction ) ; } ) ; } ) ;