From fa6d72bb638ed86e80c55d8567fbec691a275f07 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Wed, 7 Oct 2020 13:00:59 +0200 Subject: [PATCH] test(AWS API Gateway): Fix default override test --- .../apiGateway/lib/method/index.test.js | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js b/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js index a1a681de7..84434f5e0 100644 --- a/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js +++ b/lib/plugins/aws/package/compile/events/apiGateway/lib/method/index.test.js @@ -1342,37 +1342,6 @@ describe('#compileMethods()', () => { }); }); - it('should delete the default "application/x-www-form-urlencoded" template if it\'s overriden with null', () => { - awsCompileApigEvents.validated.events = [ - { - functionName: 'Second', - http: { - method: 'get', - path: 'users/list', - integration: 'AWS', - request: { - template: { - 'application/x-www-form-urlencoded': null, - }, - }, - response: { - statusCodes: { - 200: { - pattern: '', - }, - }, - }, - }, - }, - ]; - return awsCompileApigEvents.compileMethods().then(() => { - expect( - awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate.Resources - .ApiGatewayMethodUsersListGet.Properties.Integration.RequestTemplates - ).to.not.have.key('application/x-www-form-urlencoded'); - }); - }); - it('should use defined pass-through behavior', () => { awsCompileApigEvents.validated.events = [ { @@ -1930,3 +1899,36 @@ describe('#compileMethods()', () => { }); }); }); + +describe('#compileMethods v2()', () => { + describe('request configuration', () => { + it('should delete the default "application/x-www-form-urlencoded" template if it\'s overriden with null', async () => { + const { + awsNaming, + cfTemplate: { Resources: cfResources }, + } = await runServerless({ + fixture: 'apiGateway', + configExt: { + functions: { + foo: { + events: [ + { + http: { + integration: 'AWS', + request: { template: { 'application/x-www-form-urlencoded': null } }, + }, + }, + ], + }, + }, + }, + cliArgs: ['package'], + }); + const apiGatewayMethodConfig = cfResources[awsNaming.getMethodLogicalId('Foo', 'GET')]; + + expect(apiGatewayMethodConfig.Properties.Integration.RequestTemplates).to.not.have.property( + 'application/x-www-form-urlencoded' + ); + }); + }); +});