@@ -7,7 +7,9 @@ describe('<Automations> Basic', function() {
77 forTest ( this )
88
99 const FLOW_NAME = 'FlowName'
10+ const FLOW_ID = 'FlowID'
1011 const TRIGGER_NAME = 'TriggerName'
12+ const TRIGGER_ID = 'TriggerID'
1113
1214 describe ( 'activate flow by name' , function ( ) {
1315 it ( 'success' , async ( ) => {
@@ -68,6 +70,60 @@ describe('<Automations> Basic', function() {
6870 } )
6971 } )
7072
73+ describe ( 'activate flow by id' , function ( ) {
74+ it ( 'success' , async ( ) => {
75+ const req1 = prepareMockRequest ( )
76+ const req2 = prepareMockRequest ( )
77+ await Backendless . Automations . activateFlowById ( FLOW_ID )
78+ await Backendless . Automations . activateFlowById ( FLOW_ID , { name : 'Nick' } )
79+
80+ expect ( req1 ) . to . deep . include ( {
81+ method : 'POST' ,
82+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /activate` ,
83+ body : { }
84+ } )
85+
86+ expect ( req2 ) . to . deep . include ( {
87+ method : 'POST' ,
88+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /activate` ,
89+ body : {
90+ name : 'Nick' ,
91+ }
92+ } )
93+
94+ } )
95+
96+ it ( 'fails when flow id is invalid' , async ( ) => {
97+ const errorMsg = 'The "flowId" argument must be provided and must be a string.'
98+
99+ await expect ( Backendless . Automations . activateFlowById ( ) ) . to . eventually . be . rejectedWith ( errorMsg )
100+ await expect ( Backendless . Automations . activateFlowById ( undefined ) ) . to . eventually . be . rejectedWith ( errorMsg )
101+ await expect ( Backendless . Automations . activateFlowById ( null ) ) . to . eventually . be . rejectedWith ( errorMsg )
102+ await expect ( Backendless . Automations . activateFlowById ( true ) ) . to . eventually . be . rejectedWith ( errorMsg )
103+ await expect ( Backendless . Automations . activateFlowById ( false ) ) . to . eventually . be . rejectedWith ( errorMsg )
104+ await expect ( Backendless . Automations . activateFlowById ( 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
105+ await expect ( Backendless . Automations . activateFlowById ( 123 ) ) . to . eventually . be . rejectedWith ( errorMsg )
106+ await expect ( Backendless . Automations . activateFlowById ( '' ) ) . to . eventually . be . rejectedWith ( errorMsg )
107+ await expect ( Backendless . Automations . activateFlowById ( { } ) ) . to . eventually . be . rejectedWith ( errorMsg )
108+ await expect ( Backendless . Automations . activateFlowById ( [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
109+ await expect ( Backendless . Automations . activateFlowById ( ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
110+ } )
111+
112+ it ( 'fails when initial data is invalid' , async ( ) => {
113+ const errorMsg = 'The "initialData" argument must be an object with an arbitrary structure.'
114+
115+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , null ) ) . to . eventually . be . rejectedWith ( errorMsg )
116+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , true ) ) . to . eventually . be . rejectedWith ( errorMsg )
117+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , false ) ) . to . eventually . be . rejectedWith ( errorMsg )
118+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
119+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , 123 ) ) . to . eventually . be . rejectedWith ( errorMsg )
120+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , 'asd' ) ) . to . eventually . be . rejectedWith ( errorMsg )
121+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , '' ) ) . to . eventually . be . rejectedWith ( errorMsg )
122+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
123+ await expect ( Backendless . Automations . activateFlowById ( FLOW_ID , ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
124+ } )
125+ } )
126+
71127 describe ( 'activate flow trigger' , function ( ) {
72128 it ( 'success' , async ( ) => {
73129 const req1 = prepareMockRequest ( )
@@ -110,9 +166,9 @@ describe('<Automations> Basic', function() {
110166 it ( 'fails when trigger name is invalid' , async ( ) => {
111167 const errorMsg = 'The "triggerName" argument must be provided and must be a string.'
112168
113- await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , ) ) . to . eventually . be . rejectedWith ( errorMsg )
169+ await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , ) ) . to . eventually . be . rejectedWith ( errorMsg )
114170 await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , undefined ) ) . to . eventually . be . rejectedWith ( errorMsg )
115- await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , null ) ) . to . eventually . be . rejectedWith ( errorMsg )
171+ await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , null ) ) . to . eventually . be . rejectedWith ( errorMsg )
116172 await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , true ) ) . to . eventually . be . rejectedWith ( errorMsg )
117173 await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , false ) ) . to . eventually . be . rejectedWith ( errorMsg )
118174 await expect ( Backendless . Automations . activateFlowTrigger ( FLOW_NAME , 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
@@ -138,4 +194,74 @@ describe('<Automations> Basic', function() {
138194 } )
139195 } )
140196
197+ describe ( 'activate flow trigger by id' , function ( ) {
198+ it ( 'success' , async ( ) => {
199+ const req1 = prepareMockRequest ( )
200+ const req2 = prepareMockRequest ( )
201+ await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID )
202+ await Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , { name : 'Nick' } )
203+
204+ expect ( req1 ) . to . deep . include ( {
205+ method : 'POST' ,
206+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /trigger/${ TRIGGER_ID } /activate` ,
207+ body : { } ,
208+ } )
209+
210+ expect ( req2 ) . to . deep . include ( {
211+ method : 'POST' ,
212+ path : `${ APP_PATH } /automation/flow/${ FLOW_ID } /trigger/${ TRIGGER_ID } /activate` ,
213+ body : {
214+ name : 'Nick' ,
215+ }
216+ } )
217+
218+ } )
219+
220+ it ( 'fails when flow id is invalid' , async ( ) => {
221+ const errorMsg = 'The "flowId" argument must be provided and must be a string.'
222+
223+ await expect ( Backendless . Automations . activateFlowTriggerById ( ) ) . to . eventually . be . rejectedWith ( errorMsg )
224+ await expect ( Backendless . Automations . activateFlowTriggerById ( undefined ) ) . to . eventually . be . rejectedWith ( errorMsg )
225+ await expect ( Backendless . Automations . activateFlowTriggerById ( null ) ) . to . eventually . be . rejectedWith ( errorMsg )
226+ await expect ( Backendless . Automations . activateFlowTriggerById ( true ) ) . to . eventually . be . rejectedWith ( errorMsg )
227+ await expect ( Backendless . Automations . activateFlowTriggerById ( false ) ) . to . eventually . be . rejectedWith ( errorMsg )
228+ await expect ( Backendless . Automations . activateFlowTriggerById ( 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
229+ await expect ( Backendless . Automations . activateFlowTriggerById ( 123 ) ) . to . eventually . be . rejectedWith ( errorMsg )
230+ await expect ( Backendless . Automations . activateFlowTriggerById ( '' ) ) . to . eventually . be . rejectedWith ( errorMsg )
231+ await expect ( Backendless . Automations . activateFlowTriggerById ( { } ) ) . to . eventually . be . rejectedWith ( errorMsg )
232+ await expect ( Backendless . Automations . activateFlowTriggerById ( [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
233+ await expect ( Backendless . Automations . activateFlowTriggerById ( ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
234+ } )
235+
236+ it ( 'fails when trigger id is invalid' , async ( ) => {
237+ const errorMsg = 'The "triggerId" argument must be provided and must be a string.'
238+
239+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , ) ) . to . eventually . be . rejectedWith ( errorMsg )
240+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , undefined ) ) . to . eventually . be . rejectedWith ( errorMsg )
241+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , null ) ) . to . eventually . be . rejectedWith ( errorMsg )
242+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , true ) ) . to . eventually . be . rejectedWith ( errorMsg )
243+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , false ) ) . to . eventually . be . rejectedWith ( errorMsg )
244+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
245+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , 123 ) ) . to . eventually . be . rejectedWith ( errorMsg )
246+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , '' ) ) . to . eventually . be . rejectedWith ( errorMsg )
247+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , { } ) ) . to . eventually . be . rejectedWith ( errorMsg )
248+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
249+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
250+ } )
251+
252+ it ( 'fails when data is invalid' , async ( ) => {
253+ const errorMsg = 'The "data" argument must be an object with an arbitrary structure.'
254+
255+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , null ) ) . to . eventually . be . rejectedWith ( errorMsg )
256+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , true ) ) . to . eventually . be . rejectedWith ( errorMsg )
257+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , false ) ) . to . eventually . be . rejectedWith ( errorMsg )
258+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , 0 ) ) . to . eventually . be . rejectedWith ( errorMsg )
259+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , 123 ) ) . to . eventually . be . rejectedWith ( errorMsg )
260+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , 'asd' ) ) . to . eventually . be . rejectedWith ( errorMsg )
261+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , '' ) ) . to . eventually . be . rejectedWith ( errorMsg )
262+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , [ ] ) ) . to . eventually . be . rejectedWith ( errorMsg )
263+ await expect ( Backendless . Automations . activateFlowTriggerById ( FLOW_ID , TRIGGER_ID , ( ) => ( { } ) ) ) . to . eventually . be . rejectedWith ( errorMsg )
264+ } )
265+ } )
266+
141267} )
0 commit comments