@@ -82,6 +82,7 @@ describe('#methods()', () => {
8282 . to . have . property ( 'Integration' ) ;
8383 } ) ;
8484
85+ // Remove these 2 specs
8586 it ( 'should set stateMachinelogical ID to RequestTemplates when customName is not set' , ( ) => {
8687 expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' ) . Properties
8788 . Integration . RequestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
@@ -115,6 +116,81 @@ describe('#methods()', () => {
115116 } ) ;
116117 } ) ;
117118
119+ describe ( '#getIntegrationRequestTemplates()' , ( ) => {
120+ it ( 'should set stateMachinelogical ID in default templates when customName is not set' , ( ) => {
121+ expect ( serverlessStepFunctions . getIntegrationRequestTemplates ( 'stateMachine' )
122+ [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
123+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
124+ } ) ;
125+
126+ it ( 'should set custom stateMachinelogical ID in default templates when customName is set' ,
127+ ( ) => {
128+ expect ( serverlessStepFunctions . getIntegrationRequestTemplates ( 'stateMachine' , 'custom' )
129+ [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
130+ . to . be . equal ( 'Custom' ) ;
131+ } ) ;
132+
133+ it ( 'should return the default template for application/json when one is not given' , ( ) => {
134+ const http_without_request_template = {
135+ path : 'foo/bar1' ,
136+ method : 'post' ,
137+ request : {
138+ template : {
139+ 'application/x-www-form-urlencoded' : 'custom template'
140+ }
141+ }
142+ }
143+ expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , undefined , http_without_request_template )
144+ . Properties . Integration . RequestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
145+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
146+ } ) ;
147+
148+ it ( 'should return a custom template for application/json when one is given' , ( ) => {
149+ const http_with_request_template = {
150+ path : 'foo/bar1' ,
151+ method : 'post' ,
152+ request : {
153+ template : {
154+ 'application/json' : 'custom template'
155+ }
156+ }
157+ }
158+ expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , undefined , http_with_request_template )
159+ . Properties . Integration . RequestTemplates [ 'application/json' ] )
160+ . to . be . equal ( 'custom template' ) ;
161+ } ) ;
162+
163+ it ( 'should return the default template for application/x-www-form-urlencoded when one is not given' , ( ) => {
164+ const http_without_request_template = {
165+ path : 'foo/bar1' ,
166+ method : 'post' ,
167+ request : {
168+ template : {
169+ 'application/json' : 'custom template'
170+ }
171+ }
172+ }
173+ expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , undefined , http_without_request_template )
174+ . Properties . Integration . RequestTemplates [ 'application/x-www-form-urlencoded' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
175+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
176+ } ) ;
177+
178+ it ( 'should return a custom template for application/x-www-form-urlencoded when one is given' , ( ) => {
179+ const http_with_request_template = {
180+ path : 'foo/bar1' ,
181+ method : 'post' ,
182+ request : {
183+ template : {
184+ 'application/x-www-form-urlencoded' : 'custom template'
185+ }
186+ }
187+ }
188+ expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , undefined , http_with_request_template )
189+ . Properties . Integration . RequestTemplates [ 'application/x-www-form-urlencoded' ] )
190+ . to . be . equal ( 'custom template' ) ;
191+ } ) ;
192+ } ) ;
193+
118194 describe ( '#getMethodResponses()' , ( ) => {
119195 it ( 'should return a corresponding methodResponses resource' , ( ) => {
120196 expect ( serverlessStepFunctions . getMethodResponses ( ) . Properties )
0 commit comments