@@ -15,7 +15,11 @@ describe('#compileIamRole', () => {
1515 serverless . service . service = 'step-functions' ;
1616 serverless . service . provider . compiledCloudFormationTemplate = { Resources : { } } ;
1717 serverless . setProvider ( 'aws' , new AwsProvider ( serverless ) ) ;
18- serverlessStepFunctions = new ServerlessStepFunctions ( serverless ) ;
18+ const options = {
19+ stage : 'dev' ,
20+ region : 'us-east-1' ,
21+ } ;
22+ serverlessStepFunctions = new ServerlessStepFunctions ( serverless , options ) ;
1923 } ) ;
2024
2125 it ( 'should do nothing when role property exists in all statmachine properties' , ( ) => {
@@ -38,6 +42,27 @@ describe('#compileIamRole', () => {
3842 ) . to . deep . equal ( { } ) ;
3943 } ) ;
4044
45+ it ( 'should replace [region] and [policyname] with corresponding values' , ( ) => {
46+ serverless . service . stepFunctions = {
47+ stateMachines : {
48+ myStateMachine2 : {
49+ definition : 'definition' ,
50+ } ,
51+ } ,
52+ } ;
53+
54+ serverlessStepFunctions . compileIamRole ( ) ;
55+ expect ( serverlessStepFunctions . serverless . service
56+ . provider . compiledCloudFormationTemplate . Resources . IamRoleStateMachineExecution
57+ . Properties . AssumeRolePolicyDocument . Statement [ 0 ] . Principal . Service )
58+ . to . be . equal ( 'states.us-east-1.amazonaws.com' ) ;
59+
60+ expect ( serverlessStepFunctions . serverless . service
61+ . provider . compiledCloudFormationTemplate . Resources . IamRoleStateMachineExecution
62+ . Properties . Policies [ 0 ] . PolicyName )
63+ . to . be . equal ( 'dev-us-east-1-step-functions-statemachine' ) ;
64+ } ) ;
65+
4166 it ( 'should create corresponding resources when role property are not given' , ( ) => {
4267 serverless . service . stepFunctions = {
4368 stateMachines : {
@@ -50,7 +75,6 @@ describe('#compileIamRole', () => {
5075 } ,
5176 } ,
5277 } ;
53-
5478 serverlessStepFunctions . compileIamRole ( ) ;
5579 expect ( serverlessStepFunctions . serverless . service
5680 . provider . compiledCloudFormationTemplate . Resources . IamRoleStateMachineExecution . Type
0 commit comments