@@ -8,6 +8,9 @@ describe('<Automations> Basic', function() {
88
99 const FLOW_NAME = 'FlowName'
1010 const FLOW_ID = 'FlowID'
11+ const EXECUTION_ID = 'ExecutionID'
12+ const EXECUTION_ANY = 'any'
13+ const EXECUTION_ALL = 'all'
1114 const TRIGGER_NAME = 'TriggerName'
1215 const TRIGGER_ID = 'TriggerID'
1316
@@ -198,8 +201,15 @@ describe('<Automations> Basic', function() {
198201 it ( 'success' , async ( ) => {
199202 const req1 = prepareMockRequest ( )
200203 const req2 = prepareMockRequest ( )
204+ const req3 = prepareMockRequest ( )
205+ const req4 = prepareMockRequest ( )
206+ const req5 = prepareMockRequest ( )
207+
201208 await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID )
202209 await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { name : 'Nick' } )
210+ await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { name : 'Nick' } , EXECUTION_ID )
211+ await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { name : 'Nick' } , EXECUTION_ANY )
212+ await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { name : 'Nick' } , EXECUTION_ALL )
203213
204214 expect ( req1 ) . to . deep . include ( {
205215 method : 'POST' ,
@@ -215,6 +225,30 @@ describe('<Automations> Basic', function() {
215225 }
216226 } )
217227
228+ expect ( req3 ) . to . deep . include ( {
229+ method : 'POST' ,
230+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /trigger/${ TRIGGER_ID } /activate?execution=ExecutionID` ,
231+ body : {
232+ name : 'Nick' ,
233+ }
234+ } )
235+
236+ expect ( req4 ) . to . deep . include ( {
237+ method : 'POST' ,
238+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /trigger/${ TRIGGER_ID } /activate?execution=any` ,
239+ body : {
240+ name : 'Nick' ,
241+ }
242+ } )
243+
244+ expect ( req5 ) . to . deep . include ( {
245+ method : 'POST' ,
246+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /trigger/${ TRIGGER_ID } /activate?execution=all` ,
247+ body : {
248+ name : 'Nick' ,
249+ }
250+ } )
251+
218252 } )
219253
220254 it ( 'fails when flow id is invalid' , async ( ) => {
@@ -262,6 +296,20 @@ describe('<Automations> Basic', function() {
262296 await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
263297 await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
264298 } )
299+
300+ it ( 'fails when execution id is invalid' , async ( ) => {
301+ // eslint-disable-next-line
302+ const errorMsg = 'The "execution" argument must be a non-empty string and must be one of this values: "any", "all" or Execution ID.'
303+
304+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , null ) ) . to . eventually . be . rejectedWith ( errorMsg )
305+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , true ) ) . to . eventually . be . rejectedWith ( errorMsg )
306+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , false ) ) . to . eventually . be . rejectedWith ( errorMsg )
307+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
308+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , 123 ) ) . to . eventually . be . rejectedWith ( errorMsg )
309+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
310+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
311+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { } , '' ) ) . to . eventually . be . rejectedWith ( errorMsg )
312+ } )
265313 } )
266314
267315} )
0 commit comments