1717
1818import { expect } from 'chai'
1919import WorkflowState from '@/model/WorkflowState.model'
20- import {
21- applyDeltasAdded ,
22- applyDeltasUpdated ,
23- applyDeltasPruned
24- } from '@/components/cylc/gscan/deltas'
20+ import applyGScanDeltas from '@/components/cylc/gscan/deltas'
2521
2622describe ( 'GScan component' , ( ) => {
27- let workflows
23+ let gscan
2824 let newWorkflow
2925 beforeEach ( ( ) => {
30- workflows = { }
26+ gscan = {
27+ lookup : { } ,
28+ tree : [ ]
29+ }
3130 newWorkflow = {
3231 id : 'cylc|test' ,
3332 status : WorkflowState . PAUSED
@@ -36,50 +35,61 @@ describe('GScan component', () => {
3635 describe ( 'Deltas' , ( ) => {
3736 describe ( 'Added' , ( ) => {
3837 it ( 'should apply added deltas' , ( ) => {
39- const deltas = {
40- added : {
41- workflow : newWorkflow
38+ const data = {
39+ deltas : {
40+ added : {
41+ workflow : newWorkflow
42+ }
4243 }
4344 }
44- applyDeltasAdded ( deltas . added , workflows )
45- expect ( workflows [ newWorkflow . id ] ) . to . not . equal ( undefined )
45+ applyGScanDeltas ( data , gscan , { } )
46+ expect ( gscan . lookup [ newWorkflow . id ] ) . to . not . equal ( undefined )
47+ expect ( gscan . tree [ 0 ] ) . to . not . equal ( undefined )
4648 } )
4749 } )
4850 describe ( 'Updated' , ( ) => {
4951 it ( 'should apply updated deltas' , ( ) => {
50- const deltasAdded = {
51- added : {
52- workflow : newWorkflow
52+ const data = {
53+ deltas : {
54+ added : {
55+ workflow : newWorkflow
56+ }
5357 }
5458 }
55- applyDeltasAdded ( deltasAdded . added , workflows )
56- expect ( workflows [ newWorkflow . id ] . status ) . to . equal ( WorkflowState . PAUSED )
59+ applyGScanDeltas ( data , gscan , { } )
60+ expect ( gscan . lookup [ newWorkflow . id ] . node . status ) . to . equal ( WorkflowState . PAUSED )
5761 newWorkflow . status = WorkflowState . STOPPED
58- const deltasUpdated = {
59- updated : {
60- workflow : newWorkflow
62+ const updateData = {
63+ deltas : {
64+ updated : {
65+ workflow : newWorkflow
66+ }
6167 }
6268 }
63- applyDeltasUpdated ( deltasUpdated . updated , workflows )
64- expect ( workflows [ newWorkflow . id ] . status ) . to . equal ( WorkflowState . STOPPED )
69+ applyGScanDeltas ( updateData , gscan , { } )
70+ expect ( gscan . lookup [ newWorkflow . id ] . node . status ) . to . equal ( WorkflowState . STOPPED )
6571 } )
6672 } )
6773 describe ( 'Pruned' , ( ) => {
6874 it ( 'should apply pruned deltas' , ( ) => {
69- const deltasAdded = {
70- added : {
71- workflow : newWorkflow
75+ const data = {
76+ deltas : {
77+ added : {
78+ workflow : newWorkflow
79+ }
7280 }
7381 }
74- applyDeltasAdded ( deltasAdded . added , workflows )
75- expect ( workflows [ newWorkflow . id ] ) . to . not . equal ( undefined )
76- const deltasPruned = {
77- pruned : {
78- workflow : newWorkflow . id
82+ applyGScanDeltas ( data , gscan , { } )
83+ expect ( gscan . lookup [ newWorkflow . id ] ) . to . not . equal ( undefined )
84+ const prunedData = {
85+ deltas : {
86+ pruned : {
87+ workflow : newWorkflow . id
88+ }
7989 }
8090 }
81- applyDeltasPruned ( deltasPruned . pruned , workflows )
82- expect ( workflows [ newWorkflow . id ] ) . to . equal ( undefined )
91+ applyGScanDeltas ( prunedData , gscan , { } )
92+ expect ( gscan . lookup [ newWorkflow . id ] ) . to . equal ( undefined )
8393 } )
8494 } )
8595 } )
0 commit comments