Skip to content

Commit c843043

Browse files
add unit test
1 parent 3011326 commit c843043

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@ describe('#compileRestApi()', () => {
99
let serverless;
1010
let serverlessStepFunctions;
1111

12-
const serviceResourcesAwsResourcesObjectMock = {
13-
Resources: {
14-
ApiGatewayRestApi: {
15-
Type: 'AWS::ApiGateway::RestApi',
16-
Properties: {
17-
Name: 'dev-new-service',
18-
EndpointConfiguration: {
19-
Types: ['EDGE'],
12+
const serviceresourcesawsresourcesprivateobjectmock = {
13+
resources: {
14+
apigatewayrestapi: {
15+
type: 'aws::apigateway::restapi',
16+
properties: {
17+
name: 'dev-new-service',
18+
endpointconfiguration: {
19+
vpcEndpointIds: ["vpc-0a60eb65b4foo", "vpc-0a60eb65b4bar"],
20+
types: ['private'],
21+
},
22+
},
23+
},
24+
},
25+
};
26+
27+
const serviceresourcesawsresourcesobjectmock = {
28+
resources: {
29+
apigatewayrestapi: {
30+
type: 'aws::apigateway::restapi',
31+
properties: {
32+
name: 'dev-new-service',
33+
endpointconfiguration: {
34+
types: ['edge'],
2035
},
2136
},
2237
},
@@ -135,8 +150,14 @@ describe('#compileRestApi()', () => {
135150
expect(() => serverlessStepFunctions.compileRestApi()).to.not.throw(Error);
136151
});
137152

138-
it('should compile if endpointType property is PRIVATE', () => {
153+
it('should not compile if endpointType property is PRIVATE and no vpcEndpointIds', () => {
154+
serverlessStepFunctions.serverless.service.provider.endpointType = 'PRIVATE';
155+
expect(() => serverlessStepFunctions.compileRestApi()).to.throw(Error);
156+
});
157+
158+
it('should compile if endpointType property is PRIVATE and vpcEndpointIds', () => {
139159
serverlessStepFunctions.serverless.service.provider.endpointType = 'PRIVATE';
160+
serverlessStepFunctions.serverless.service.provider.vpcEndpointIds = ["vpc-0a60eb65b4foo", "vpc-0a60eb65b4bar"];
140161
expect(() => serverlessStepFunctions.compileRestApi()).to.not.throw(Error);
141162
});
142163

0 commit comments

Comments
 (0)