@@ -435,13 +435,34 @@ describe('ServerlessStepFunctions', () => {
435
435
436
436
describe ( '#describeExecution()' , ( ) => {
437
437
let describeExecutionStub ;
438
- beforeEach ( ( ) => {
438
+ it ( 'should describeExecution with correct params' , ( ) => {
439
439
describeExecutionStub = sinon . stub ( serverlessStepFunctions . provider , 'request' )
440
440
. 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
+ } ) ;
441
456
} ) ;
442
457
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 ( )
445
466
. then ( ( ) => {
446
467
expect ( describeExecutionStub . calledOnce ) . to . be . equal ( true ) ;
447
468
expect ( describeExecutionStub . calledWithExactly (
@@ -453,6 +474,33 @@ describe('ServerlessStepFunctions', () => {
453
474
serverlessStepFunctions . options . stage ,
454
475
serverlessStepFunctions . options . region
455
476
) ) . 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 ) ;
456
504
serverlessStepFunctions . provider . request . restore ( ) ;
457
505
} )
458
506
) ;
@@ -473,9 +521,26 @@ describe('ServerlessStepFunctions', () => {
473
521
expect ( serverlessStepFunctions . stepFunctions ) . to . be . equal ( 'stepFunctions' ) ;
474
522
} )
475
523
) ;
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
+ } ) ;
476
532
} ) ;
477
533
478
534
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
+
479
544
it ( 'should comple with correct params' , ( ) => {
480
545
serverlessStepFunctions . stepFunctions = {
481
546
stateMachine : {
0 commit comments