@@ -31,6 +31,7 @@ describe('ServerlessStepFunctions', () => {
3131 state : 'stateMachine' ,
3232 data : 'inputData' ,
3333 } ;
34+
3435 serverless . init ( ) ;
3536 serverless . setProvider ( 'aws' , new AwsProvider ( serverless ) ) ;
3637 serverlessStepFunctions = new ServerlessStepFunctions ( serverless , options ) ;
@@ -334,7 +335,30 @@ describe('ServerlessStepFunctions', () => {
334335 } ) ;
335336
336337 describe ( '#createStateMachine()' , ( ) => {
337- // todo
338+ let createStateMachineStub ;
339+ beforeEach ( ( ) => {
340+ createStateMachineStub = sinon . stub ( serverlessStepFunctions . provider , 'request' )
341+ . returns ( BbPromise . resolve ( ) ) ;
342+ } ) ;
343+
344+ it ( 'should createStateMachine with correct params'
345+ , ( ) => serverlessStepFunctions . createStateMachine ( )
346+ . then ( ( ) => {
347+ expect ( createStateMachineStub . calledOnce ) . to . be . equal ( true ) ;
348+ expect ( createStateMachineStub . calledWithExactly (
349+ 'StepFunctions' ,
350+ 'createStateMachine' ,
351+ {
352+ definition : serverlessStepFunctions . awsStateLanguage [ serverlessStepFunctions . options . state ] ,
353+ name : `${ serverlessStepFunctions . options . state } -${ serverlessStepFunctions . options . stage } ` ,
354+ roleArn : serverlessStepFunctions . iamRoleArn ,
355+ } ,
356+ serverlessStepFunctions . options . stage ,
357+ serverlessStepFunctions . options . region
358+ ) ) . to . be . equal ( true ) ;
359+ serverlessStepFunctions . provider . request . restore ( ) ;
360+ } )
361+ ) ;
338362 } ) ;
339363
340364 describe ( '#startExecution()' , ( ) => {
@@ -389,11 +413,45 @@ describe('ServerlessStepFunctions', () => {
389413 } ) ;
390414
391415 describe ( '#yamlParse()' , ( ) => {
392- // todo
416+ let yamlParserStub ;
417+ beforeEach ( ( ) => {
418+ yamlParserStub = sinon . stub ( serverlessStepFunctions . serverless . yamlParser , 'parse' )
419+ . returns ( BbPromise . resolve ( { stepFunctions : 'stepFunctions' } ) ) ;
420+ serverlessStepFunctions . serverless . config . servicePath = 'servicePath' ;
421+ } ) ;
422+
423+ it ( 'should yamlParse with correct params'
424+ , ( ) => serverlessStepFunctions . yamlParse ( )
425+ . then ( ( ) => {
426+ expect ( yamlParserStub . calledOnce ) . to . be . equal ( true ) ;
427+ expect ( serverlessStepFunctions . stepFunctions ) . to . be . equal ( 'stepFunctions' ) ;
428+ } )
429+ ) ;
393430 } ) ;
394431
395432 describe ( '#compile()' , ( ) => {
396- // todo
433+ beforeEach ( ( ) => {
434+ serverlessStepFunctions . stepFunctions = {
435+ stateMachine : {
436+ States : {
437+ HelloWorld : {
438+ Resource : 'first' ,
439+ } ,
440+ } ,
441+ } ,
442+ } ;
443+ serverlessStepFunctions . functionArns . first = 'lambdaArn' ;
444+ } ) ;
445+
446+ it ( 'should comple with correct params'
447+ , ( ) => serverlessStepFunctions . compile ( )
448+ . then ( ( ) => {
449+ expect ( serverlessStepFunctions . stepFunctions . stateMachine . States . HelloWorld . Resource )
450+ . to . be . equal ( 'lambdaArn' ) ;
451+ expect ( serverlessStepFunctions . awsStateLanguage . stateMachine )
452+ . to . be . equal ( '{"States":{"HelloWorld":{"Resource":"lambdaArn"}}}' ) ;
453+ } )
454+ ) ;
397455 } ) ;
398456} ) ;
399457
0 commit comments