@@ -153,6 +153,27 @@ describe('activity', () => {
153153 ) ;
154154 } ) ;
155155
156+ describe ( '#deleteActivities()' , ( ) => {
157+ let deleteActivityStub ;
158+ beforeEach ( ( ) => {
159+ serverlessStepFunctions . deployedActivities = {
160+ helloHello : 'deployed' ,
161+ hogeHoge : 'deployed' ,
162+ sssss : 'notDeployed' ,
163+ } ;
164+ deleteActivityStub = sinon
165+ . stub ( serverlessStepFunctions , 'deleteActivity' ) . returns ( BbPromise . resolve ( ) ) ;
166+ } ) ;
167+
168+ it ( 'should deleteActivities with correct params'
169+ , ( ) => serverlessStepFunctions . deleteActivities ( )
170+ . then ( ( ) => {
171+ expect ( deleteActivityStub . calledTwice ) . to . be . equal ( true ) ;
172+ serverlessStepFunctions . deleteActivity . restore ( ) ;
173+ } )
174+ ) ;
175+ } ) ;
176+
156177 describe ( '#describeActivity()' , ( ) => {
157178 let describeActivityResolveStub ;
158179 let describeActivityRejectStub ;
@@ -247,4 +268,117 @@ describe('activity', () => {
247268 } ) ;
248269 } ) ;
249270 } ) ;
271+
272+ describe ( '#describeActivities()' , ( ) => {
273+ let describeActivityStub ;
274+ beforeEach ( ( ) => {
275+ serverless . service . stepFunctions . activities = [
276+ 'helloHello' ,
277+ 'hogeHoge' ,
278+ ] ;
279+ describeActivityStub = sinon
280+ . stub ( serverlessStepFunctions , 'describeActivity' ) . returns ( BbPromise . resolve ( ) ) ;
281+ } ) ;
282+
283+ it ( 'should deleteActivities with correct params'
284+ , ( ) => serverlessStepFunctions . describeActivities ( )
285+ . then ( ( ) => {
286+ expect ( describeActivityStub . calledTwice ) . to . be . equal ( true ) ;
287+ serverlessStepFunctions . describeActivity . restore ( ) ;
288+ } )
289+ ) ;
290+ } ) ;
291+
292+ describe ( '#checkActivitySettings()' , ( ) => {
293+ it ( 'should throw error when activities does not exists' , ( ) => {
294+ expect ( ( ) => serverlessStepFunctions . checkActivitySettings ( ) ) . to . throw ( Error ) ;
295+ } ) ;
296+
297+ it ( 'should return resolve when activities exists' , ( done ) => {
298+ serverlessStepFunctions . serverless . service . stepFunctions . activities = true ;
299+ serverlessStepFunctions . checkActivitySettings ( ) . then ( ( ) => done ( ) ) ;
300+ } ) ;
301+ } ) ;
302+
303+ describe ( '#checkActivitySetting()' , ( ) => {
304+ beforeEach ( ( ) => {
305+ serverless . service . stepFunctions . activities = [
306+ 'helloActivity' ,
307+ 'name' ,
308+ ] ;
309+ } ) ;
310+
311+ it ( 'should throw error when activity does not exists' , ( ) => {
312+ serverlessStepFunctions . serverless . service . stepFunctions . activities = [ ] ;
313+ expect ( ( ) => serverlessStepFunctions . checkActivitySetting ( ) ) . to . throw ( Error ) ;
314+ } ) ;
315+
316+ it ( 'should return respleve when correct params is not given' , ( done ) => {
317+ serverlessStepFunctions . checkActivitySetting ( ) . then ( ( ) => done ( ) ) ;
318+ } ) ;
319+
320+ it ( 'should return respleve with correct params' , ( done ) => {
321+ serverlessStepFunctions . checkActivitySetting ( 'name' ) . then ( ( ) => done ( ) ) ;
322+ } ) ;
323+ } ) ;
324+
325+ describe ( '#getActivityArn()' , ( ) => {
326+ let getActivityArnStub ;
327+ beforeEach ( ( ) => {
328+ getActivityArnStub = sinon . stub ( serverlessStepFunctions . provider , 'request' )
329+ . returns ( BbPromise . resolve ( { Account : 1234 } ) ) ;
330+ } ) ;
331+
332+ it ( 'should getActivityArn when correct params is not given' , ( ) => {
333+ serverlessStepFunctions . getActivityArn ( ) . then ( ( ) => {
334+ expect ( getActivityArnStub . calledOnce ) . to . be . equal ( true ) ;
335+ expect ( getActivityArnStub . calledWithExactly (
336+ 'STS' ,
337+ 'getCallerIdentity' ,
338+ { } ,
339+ serverlessStepFunctions . options . stage ,
340+ serverlessStepFunctions . options . region
341+ ) ) . to . be . equal ( true ) ;
342+ expect ( serverlessStepFunctions . activityArns . helloActivity ) . to . be
343+ . equal ( 'arn:aws:states:us-east-1:1234:activity:step-functions-dev-helloActivity' ) ;
344+ serverlessStepFunctions . provider . request . restore ( ) ;
345+ } ) ;
346+ } ) ;
347+
348+ it ( 'should getActivityArn with correct params' , ( ) => {
349+ serverlessStepFunctions . getActivityArn ( 'name' ) . then ( ( ) => {
350+ expect ( getActivityArnStub . calledOnce ) . to . be . equal ( true ) ;
351+ expect ( getActivityArnStub . calledWithExactly (
352+ 'STS' ,
353+ 'getCallerIdentity' ,
354+ { } ,
355+ serverlessStepFunctions . options . stage ,
356+ serverlessStepFunctions . options . region
357+ ) ) . to . be . equal ( true ) ;
358+ expect ( serverlessStepFunctions . activityArns . name ) . to . be
359+ . equal ( 'arn:aws:states:us-east-1:1234:activity:step-functions-dev-name' ) ;
360+ serverlessStepFunctions . provider . request . restore ( ) ;
361+ } ) ;
362+ } ) ;
363+ } ) ;
364+
365+ describe ( '#getActivityArns()' , ( ) => {
366+ let getActivityArnStub ;
367+ beforeEach ( ( ) => {
368+ serverless . service . stepFunctions . activities = [
369+ 'helloHello' ,
370+ 'hogeHoge' ,
371+ ] ;
372+ getActivityArnStub = sinon
373+ . stub ( serverlessStepFunctions , 'getActivityArn' ) . returns ( BbPromise . resolve ( ) ) ;
374+ } ) ;
375+
376+ it ( 'should getActivityArns with correct params'
377+ , ( ) => serverlessStepFunctions . getActivityArns ( )
378+ . then ( ( ) => {
379+ expect ( getActivityArnStub . calledTwice ) . to . be . equal ( true ) ;
380+ serverlessStepFunctions . getActivityArn . restore ( ) ;
381+ } )
382+ ) ;
383+ } ) ;
250384} ) ;
0 commit comments