@@ -975,5 +975,53 @@ describe('#compileStateMachines', () => {
975975 expect ( definition . States . Lambda2 . Resource )
976976 . to . equal ( 'arn:aws:lambda:us-east-1:1234567890:function:world' ) ;
977977 } ) ;
978+
979+ it ( 'should do nothing if there are no ref to lambda functions, even if useExactVersion is true' , ( ) => {
980+ serverless . service . stepFunctions = {
981+ stateMachines : {
982+ myStateMachine1 : {
983+ id : 'Test' ,
984+ useExactVersion : true ,
985+ definition : {
986+ StartAt : 'Sns' ,
987+ States : {
988+ Sns : {
989+ Type : 'Task' ,
990+ Resource : 'arn:aws:states:::sns:publish' ,
991+ Parameters : {
992+ Message : {
993+ 'Fn::GetAtt' : [ 'MyTopic' , 'TopicName' ] ,
994+ } ,
995+ TopicArn : {
996+ Ref : 'MyTopic' ,
997+ } ,
998+ } ,
999+ End : true ,
1000+ } ,
1001+ } ,
1002+ } ,
1003+ } ,
1004+ } ,
1005+ } ;
1006+
1007+ serverlessStepFunctions . compileStateMachines ( ) ;
1008+ const stateMachine = serverlessStepFunctions . serverless . service
1009+ . provider . compiledCloudFormationTemplate . Resources
1010+ . Test ;
1011+
1012+ expect ( stateMachine . Properties . DefinitionString ) . to . haveOwnProperty ( 'Fn::Sub' ) ;
1013+ expect ( stateMachine . Properties . DefinitionString [ 'Fn::Sub' ] ) . to . have . lengthOf ( 2 ) ;
1014+
1015+ const [ json , params ] = stateMachine . Properties . DefinitionString [ 'Fn::Sub' ] ;
1016+ const modifiedDefinition = JSON . parse ( json ) ;
1017+
1018+ const sns = modifiedDefinition . States . Sns ;
1019+ expect ( sns . Parameters . TopicArn . startsWith ( '${' ) ) . to . eq ( true ) ;
1020+ const topicArnParam = sns . Parameters . TopicArn . replace ( / [ $ { } ] / g, '' ) ;
1021+ expect ( params ) . to . haveOwnProperty ( topicArnParam ) ;
1022+ const topicArn = params [ topicArnParam ] ;
1023+
1024+ expect ( topicArn ) . to . deep . equal ( { Ref : 'MyTopic' } ) ;
1025+ } ) ;
9781026 } ) ;
9791027} ) ;
0 commit comments