Skip to content

Commit b43dd8d

Browse files
author
Or Zarchi
committed
fix: add test
1 parent a073297 commit b43dd8d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/deploy/events/apiGateway/methods.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,20 @@ describe('#methods()', () => {
284284
});
285285
});
286286

287+
describe('#getLambdaProxyRequestTemplates()', () => {
288+
it('application/json proxy template should not have escaped single quotes', () => {
289+
const lambdaProxyRequestTemplate = serverlessStepFunctions
290+
.getLambdaProxyRequestTemplates('stateMachine', undefined);
291+
292+
// Using negative lookahead, look for escapeJavaScript calls without the
293+
// required stripping of escaped single quotes after
294+
const escapeJavascriptPattern = /\$util.escapeJavaScript\("\$\w+"\)/;
295+
const unescapeSingleQuotesPattern = /\.replaceAll\("\\\\'", *"'"\)/;
296+
const regExp = new RegExp(`${escapeJavascriptPattern.source}(?!${unescapeSingleQuotesPattern.source})`);
297+
expect(lambdaProxyRequestTemplate['application/json']['Fn::Sub'][0]).not.to.match(regExp);
298+
});
299+
});
300+
287301
describe('#getMethodResponses()', () => {
288302
it('should return a corresponding methodResponses resource', () => {
289303
expect(serverlessStepFunctions.getMethodResponses().Properties)

0 commit comments

Comments
 (0)