@@ -435,13 +435,34 @@ describe('ServerlessStepFunctions', () => {
435435
436436 describe ( '#describeExecution()' , ( ) => {
437437 let describeExecutionStub ;
438- beforeEach ( ( ) => {
438+ it ( 'should describeExecution with correct params' , ( ) => {
439439 describeExecutionStub = sinon . stub ( serverlessStepFunctions . provider , 'request' )
440440 . returns ( BbPromise . resolve ( { status : 'SUCCESS' } ) ) ;
441+
442+ serverlessStepFunctions . describeExecution ( )
443+ . then ( ( ) => {
444+ expect ( describeExecutionStub . calledOnce ) . to . be . equal ( true ) ;
445+ expect ( describeExecutionStub . calledWithExactly (
446+ 'StepFunctions' ,
447+ 'describeExecution' ,
448+ {
449+ executionArn : serverlessStepFunctions . executionArn ,
450+ } ,
451+ serverlessStepFunctions . options . stage ,
452+ serverlessStepFunctions . options . region
453+ ) ) . to . be . equal ( true ) ;
454+ serverlessStepFunctions . provider . request . restore ( ) ;
455+ } ) ;
441456 } ) ;
442457
443- it ( 'should describeExecution with correct params'
444- , ( ) => serverlessStepFunctions . describeExecution ( )
458+ it ( 'should describeExecution with status FAILED' , ( ) => {
459+ describeExecutionStub = sinon . stub ( serverlessStepFunctions . provider , 'request' )
460+ . returns ( BbPromise . resolve ( { status : 'FAILED' } ) ) ;
461+ const getExecutionHistoryStub = sinon
462+ . stub ( serverlessStepFunctions , 'getExecutionHistory' )
463+ . returns ( BbPromise . resolve ( { events : [ { executionFailedEventDetails : 'error' } ] } ) ) ;
464+
465+ serverlessStepFunctions . describeExecution ( )
445466 . then ( ( ) => {
446467 expect ( describeExecutionStub . calledOnce ) . to . be . equal ( true ) ;
447468 expect ( describeExecutionStub . calledWithExactly (
@@ -453,6 +474,33 @@ describe('ServerlessStepFunctions', () => {
453474 serverlessStepFunctions . options . stage ,
454475 serverlessStepFunctions . options . region
455476 ) ) . to . be . equal ( true ) ;
477+ expect ( getExecutionHistoryStub . calledOnce ) . to . be . equal ( true ) ;
478+ serverlessStepFunctions . provider . request . restore ( ) ;
479+ serverlessStepFunctions . getExecutionHistory . restore ( ) ;
480+ } ) ;
481+ } ) ;
482+ } ) ;
483+
484+ describe ( '#getExecutionHistory()' , ( ) => {
485+ let getExecutionHistoryStub ;
486+ beforeEach ( ( ) => {
487+ getExecutionHistoryStub = sinon . stub ( serverlessStepFunctions . provider , 'request' )
488+ . returns ( BbPromise . resolve ( { events : [ { executionFailedEventDetails : 'error' } ] } ) ) ;
489+ } ) ;
490+
491+ it ( 'should getExecutionHistory with correct params'
492+ , ( ) => serverlessStepFunctions . getExecutionHistory ( )
493+ . then ( ( ) => {
494+ expect ( getExecutionHistoryStub . calledOnce ) . to . be . equal ( true ) ;
495+ expect ( getExecutionHistoryStub . calledWithExactly (
496+ 'StepFunctions' ,
497+ 'getExecutionHistory' ,
498+ {
499+ executionArn : serverlessStepFunctions . executionArn ,
500+ } ,
501+ serverlessStepFunctions . options . stage ,
502+ serverlessStepFunctions . options . region
503+ ) ) . to . be . equal ( true ) ;
456504 serverlessStepFunctions . provider . request . restore ( ) ;
457505 } )
458506 ) ;
@@ -473,9 +521,26 @@ describe('ServerlessStepFunctions', () => {
473521 expect ( serverlessStepFunctions . stepFunctions ) . to . be . equal ( 'stepFunctions' ) ;
474522 } )
475523 ) ;
524+
525+ it ( 'should return resolve when servicePath does not exists' , ( ) => {
526+ serverlessStepFunctions . serverless . config . servicePath = null ;
527+ serverlessStepFunctions . yamlParse ( )
528+ . then ( ( ) => {
529+ expect ( yamlParserStub . callCount ) . to . be . equal ( 0 ) ;
530+ } ) ;
531+ } ) ;
476532 } ) ;
477533
478534 describe ( '#compile()' , ( ) => {
535+ it ( 'should throw error when stepFunction state does not exists' , ( ) => {
536+ expect ( ( ) => serverlessStepFunctions . compile ( ) ) . to . throw ( Error ) ;
537+ } ) ;
538+
539+ it ( 'should throw error when stateMachine name does not exists' , ( ) => {
540+ serverlessStepFunctions . stepFunctions = { } ;
541+ expect ( ( ) => serverlessStepFunctions . compile ( ) ) . to . throw ( Error ) ;
542+ } ) ;
543+
479544 it ( 'should comple with correct params' , ( ) => {
480545 serverlessStepFunctions . stepFunctions = {
481546 stateMachine : {
0 commit comments