@@ -82,19 +82,6 @@ describe('#methods()', () => {
82
82
. to . have . property ( 'Integration' ) ;
83
83
} ) ;
84
84
85
- it ( 'should set stateMachinelogical ID to RequestTemplates when customName is not set' , ( ) => {
86
- expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' ) . Properties
87
- . Integration . RequestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
88
- . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
89
- } ) ;
90
-
91
- it ( 'should set custom stateMachinelogical ID to RequestTemplates when customName is set' ,
92
- ( ) => {
93
- expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , 'custom' ) . Properties
94
- . Integration . RequestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
95
- . to . be . equal ( 'Custom' ) ;
96
- } ) ;
97
-
98
85
it ( 'should set Access-Control-Allow-Origin header when cors is true' ,
99
86
( ) => {
100
87
expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , 'custom' , {
@@ -115,6 +102,93 @@ describe('#methods()', () => {
115
102
} ) ;
116
103
} ) ;
117
104
105
+ describe ( '#getIntegrationRequestTemplates()' , ( ) => {
106
+ it ( 'should set stateMachinelogical ID in default templates when customName is not set' , ( ) => {
107
+ const requestTemplates = serverlessStepFunctions
108
+ . getIntegrationRequestTemplates ( 'stateMachine' ) ;
109
+ expect ( requestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
110
+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
111
+ } ) ;
112
+
113
+ it ( 'should set custom stateMachinelogical ID in default templates when customName is set' ,
114
+ ( ) => {
115
+ const requestTemplates = serverlessStepFunctions
116
+ . getIntegrationRequestTemplates ( 'stateMachine' , 'custom' ) ;
117
+ expect ( requestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
118
+ . to . be . equal ( 'Custom' ) ;
119
+ } ) ;
120
+
121
+ it ( 'should return the default template for application/json when one is not given' , ( ) => {
122
+ const httpWithoutRequestTemplate = {
123
+ path : 'foo/bar1' ,
124
+ method : 'post' ,
125
+ request : {
126
+ template : {
127
+ 'application/x-www-form-urlencoded' : 'custom template' ,
128
+ } ,
129
+ } ,
130
+ } ;
131
+ const requestTemplates = serverlessStepFunctions
132
+ . getMethodIntegration ( 'stateMachine' , undefined , httpWithoutRequestTemplate )
133
+ . Properties . Integration . RequestTemplates ;
134
+ expect ( requestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
135
+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
136
+ } ) ;
137
+
138
+ it ( 'should return a custom template for application/json when one is given' , ( ) => {
139
+ const httpWithRequestTemplate = {
140
+ path : 'foo/bar1' ,
141
+ method : 'post' ,
142
+ request : {
143
+ template : {
144
+ 'application/json' : 'custom template' ,
145
+ } ,
146
+ } ,
147
+ } ;
148
+ const requestTemplates = serverlessStepFunctions
149
+ . getMethodIntegration ( 'stateMachine' , undefined , httpWithRequestTemplate )
150
+ . Properties . Integration . RequestTemplates ;
151
+ expect ( requestTemplates [ 'application/json' ] )
152
+ . to . be . equal ( 'custom template' ) ;
153
+ } ) ;
154
+
155
+ it ( 'should return the default for application/x-www-form-urlencoded when one is not given' ,
156
+ ( ) => {
157
+ const httpWithoutRequestTemplate = {
158
+ path : 'foo/bar1' ,
159
+ method : 'post' ,
160
+ request : {
161
+ template : {
162
+ 'application/json' : 'custom template' ,
163
+ } ,
164
+ } ,
165
+ } ;
166
+ const requestTemplates = serverlessStepFunctions
167
+ . getMethodIntegration ( 'stateMachine' , undefined , httpWithoutRequestTemplate )
168
+ . Properties . Integration . RequestTemplates ;
169
+ expect ( requestTemplates [ 'application/x-www-form-urlencoded' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
170
+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
171
+ } ) ;
172
+
173
+ it ( 'should return a custom template for application/x-www-form-urlencoded when one is given' ,
174
+ ( ) => {
175
+ const httpWithRequestTemplate = {
176
+ path : 'foo/bar1' ,
177
+ method : 'post' ,
178
+ request : {
179
+ template : {
180
+ 'application/x-www-form-urlencoded' : 'custom template' ,
181
+ } ,
182
+ } ,
183
+ } ;
184
+ const requestTemplates = serverlessStepFunctions
185
+ . getMethodIntegration ( 'stateMachine' , undefined , httpWithRequestTemplate )
186
+ . Properties . Integration . RequestTemplates ;
187
+ expect ( requestTemplates [ 'application/x-www-form-urlencoded' ] )
188
+ . to . be . equal ( 'custom template' ) ;
189
+ } ) ;
190
+ } ) ;
191
+
118
192
describe ( '#getMethodResponses()' , ( ) => {
119
193
it ( 'should return a corresponding methodResponses resource' , ( ) => {
120
194
expect ( serverlessStepFunctions . getMethodResponses ( ) . Properties )
0 commit comments