@@ -33,7 +33,7 @@ describe('workflows', () => {
3333 const resetState = ( ) => {
3434 store . state . workflows . lookup = { }
3535 store . state . workflows . workflow = {
36- tree : { } ,
36+ tree : [ ] ,
3737 lookup : { }
3838 }
3939 store . state . workflows . workflows = [ ]
@@ -44,7 +44,7 @@ describe('workflows', () => {
4444 describe ( 'State' , ( ) => {
4545 it ( 'should start with empty lookup, empty workflow, no workflows, and no workflow name' , ( ) => {
4646 expect ( Object . keys ( store . state . workflows . lookup ) . length ) . to . deep . equal ( 0 )
47- expect ( store . state . workflows . workflow ) . to . deep . equal ( { tree : { } , lookup : { } } )
47+ expect ( store . state . workflows . workflow ) . to . deep . equal ( { tree : [ ] , lookup : { } } )
4848 expect ( store . state . workflows . workflows . length ) . to . equal ( 0 )
4949 expect ( store . state . workflows . workflowName ) . to . equal ( null )
5050 } )
@@ -79,38 +79,85 @@ describe('workflows', () => {
7979 store . commit ( 'workflows/SET_WORKFLOW_NAME' , workflowName )
8080 expect ( store . state . workflows . workflowName ) . to . equal ( workflowName )
8181 } )
82- it ( 'should set workflow ' , ( ) => {
82+ it ( 'should set gscan ' , ( ) => {
8383 const workflow = {
84- tree : {
85- test : 1
86- } ,
84+ tree : [
85+ {
86+ test : 1
87+ }
88+ ] ,
8789 lookup : {
8890 test : 1
8991 }
9092 }
91- store . commit ( 'workflows/SET_WORKFLOW' , workflow )
92- expect ( store . state . workflows . workflow ) . to . deep . equal ( workflow )
93- } )
94- it ( 'should set lookup' , ( ) => {
95- const lookup = {
96- test : 1
97- }
98- store . commit ( 'workflows/SET_LOOKUP' , lookup )
99- expect ( store . state . workflows . lookup ) . to . deep . equal ( lookup )
93+ store . commit ( 'workflows/SET_GSCAN' , workflow )
94+ expect ( store . state . workflows . gscan ) . to . deep . equal ( workflow )
10095 } )
101- it ( 'should clear workflow ' , ( ) => {
96+ it ( 'should clear gscan ' , ( ) => {
10297 const workflow = {
103- tree : {
104- test : 1
105- } ,
98+ tree : [
99+ {
100+ test : 1
101+ }
102+ ] ,
106103 lookup : {
107104 test : 1
108105 }
109106 }
110- store . commit ( 'workflows/SET_WORKFLOW' , workflow )
111- expect ( store . state . workflows . workflow ) . to . deep . equal ( workflow )
112- store . commit ( 'workflows/CLEAR_WORKFLOW' , workflow )
113- expect ( store . state . workflows . workflow ) . to . not . deep . equal ( workflow )
107+ store . commit ( 'workflows/SET_GSCAN' , workflow )
108+ expect ( store . state . workflows . gscan . tree . length ) . to . equal ( 1 )
109+ expect ( Object . keys ( store . state . workflows . gscan . lookup ) . length ) . to . equal ( 1 )
110+ store . commit ( 'workflows/CLEAR_GSCAN' )
111+ expect ( store . state . workflows . gscan . tree . length ) . to . equal ( 0 )
112+ expect ( Object . keys ( store . state . workflows . gscan . lookup ) . length ) . to . equal ( 0 )
113+ } )
114+ } )
115+ describe ( 'Actions' , ( ) => {
116+ it ( 'should apply workflows deltas' , ( ) => {
117+ const data = {
118+ deltas : {
119+ added : {
120+ workflow : {
121+ id : 'cylc|test' ,
122+ status : 'test'
123+ }
124+ }
125+ }
126+ }
127+ store . dispatch ( 'workflows/applyWorkflowsDeltas' , data )
128+ store . dispatch ( 'workflows/applyGScanDeltas' , data )
129+ expect ( store . state . workflows . workflows [ 'cylc|test' ] ) . to . not . equal ( undefined )
130+ } )
131+ it ( 'should clear workflows' , ( ) => {
132+ const workflows = {
133+ 'cylc|cylc' : {
134+ id : 'cylc|cylc' ,
135+ name : 'cylc'
136+ }
137+ }
138+ store . commit ( 'workflows/SET_WORKFLOWS' , workflows )
139+ expect ( store . state . workflows . workflows ) . to . deep . equal ( workflows )
140+ store . dispatch ( 'workflows/clearWorkflows' )
141+ expect ( store . state . workflows . workflows ) . to . not . deep . equal ( workflows )
142+ } )
143+ it ( 'should set workflow name' , ( ) => {
144+ const workflowName = 'cylc'
145+ store . dispatch ( 'workflows/setWorkflowName' , workflowName )
146+ expect ( store . state . workflows . workflowName ) . to . equal ( workflowName )
147+ } )
148+ it ( 'should apply workflow deltas' , ( ) => {
149+ const data = {
150+ deltas : {
151+ added : {
152+ workflow : {
153+ id : 'cylc|test' ,
154+ status : 'test'
155+ }
156+ }
157+ }
158+ }
159+ store . dispatch ( 'workflows/applyGScanDeltas' , data )
160+ expect ( store . state . workflows . gscan . lookup [ 'cylc|test' ] ) . to . not . equal ( undefined )
114161 } )
115162 } )
116163} )
0 commit comments