mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const expect = require('chai').expect;
|
|
const AwsCompileApigEvents = require('../index');
|
|
const Serverless = require('../../../../../../../Serverless');
|
|
|
|
describe('#compileRestApi()', () => {
|
|
let serverless;
|
|
let awsCompileApigEvents;
|
|
|
|
const serviceResourcesAwsResourcesObjectMock = {
|
|
Resources: {
|
|
RestApiApigEvent: {
|
|
Type: 'AWS::ApiGateway::RestApi',
|
|
Properties: {
|
|
Name: 'dev-new-service',
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
beforeEach(() => {
|
|
serverless = new Serverless();
|
|
serverless.service.resources = { Resources: {} };
|
|
const options = {
|
|
stage: 'dev',
|
|
region: 'us-east-1',
|
|
};
|
|
awsCompileApigEvents = new AwsCompileApigEvents(serverless, options);
|
|
awsCompileApigEvents.serverless.service.service = 'new-service';
|
|
awsCompileApigEvents.serverless.service.functions = {
|
|
first: {
|
|
events: [
|
|
{
|
|
http: {
|
|
path: 'foo/bar',
|
|
method: 'POST',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
};
|
|
});
|
|
|
|
it('should create a REST API resource', () => awsCompileApigEvents
|
|
.compileRestApi().then(() => {
|
|
expect(
|
|
awsCompileApigEvents.serverless.service.resources.Resources
|
|
).to.deep.equal(
|
|
serviceResourcesAwsResourcesObjectMock.Resources
|
|
);
|
|
})
|
|
);
|
|
});
|