test(AWS API Gateway): Fix default override test

This commit is contained in:
Mariusz Nowak 2020-10-07 13:00:59 +02:00 committed by Mariusz Nowak
parent a3ebc01f2b
commit fa6d72bb63

View File

@ -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'
);
});
});
});