"use strict";
/*
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *  SPDX-License-Identifier: Apache-2.0
 */
Object.defineProperty(exports, "__esModule", { value: true });
const aws_cdk_lib_1 = require("aws-cdk-lib");
const assertions_1 = require("aws-cdk-lib/assertions");
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
const RSWVpc_1 = require("./RSWVpc");
describe('SWBvpc tests', () => {
    it('has the correct vpc properties when given no arguments', () => {
        const rswVpcPropsProps = {
            vpcId: '',
            albSubnetIds: [],
            ecsSubnetIds: []
        };
        const stack = new aws_cdk_lib_1.Stack();
        new RSWVpc_1.RSWVpc(stack, 'TestRSWVpc', rswVpcPropsProps);
        const template = assertions_1.Template.fromStack(stack);
        template.resourceCountIs('AWS::EC2::VPC', 1);
        template.resourceCountIs('AWS::EC2::Subnet', 4);
        template.resourceCountIs('AWS::EC2::RouteTable', 4);
        template.resourceCountIs('AWS::EC2::SubnetRouteTableAssociation', 4);
        template.resourceCountIs('AWS::EC2::Route', 4);
        template.resourceCountIs('AWS::EC2::EIP', 2);
        template.resourceCountIs('AWS::EC2::NatGateway', 2);
        template.resourceCountIs('AWS::EC2::InternetGateway', 1);
        template.resourceCountIs('AWS::EC2::VPCGatewayAttachment', 1);
        template.hasResourceProperties('AWS::EC2::VPC', {
            CidrBlock: '10.0.0.0/16',
            EnableDnsHostnames: true,
            EnableDnsSupport: true,
            InstanceTenancy: 'default',
            Tags: [
                {
                    Key: 'Name',
                    Value: 'Default/TestRSWVpc/MainVPC'
                }
            ]
        });
        template.hasResourceProperties('AWS::EC2::VPC', {
            CidrBlock: '10.0.0.0/16',
            EnableDnsHostnames: true,
            EnableDnsSupport: true,
            InstanceTenancy: 'default',
            Tags: [
                {
                    Key: 'Name',
                    Value: 'Default/TestRSWVpc/MainVPC'
                }
            ]
        });
        template.hasResourceProperties('AWS::EC2::Route', {
            DestinationCidrBlock: '0.0.0.0/0'
        });
    });
    it('has the correct vpc properties when given vpcId and albSubnetId', () => {
        const stack = new aws_cdk_lib_1.Stack();
        const template = assertions_1.Template.fromStack(stack);
        const mockVpc = new aws_ec2_1.Vpc(stack, 'testVpc');
        const mockSubnet = new aws_ec2_1.Subnet(stack, 'SWBSubnet1', {
            availabilityZone: 'us-east-1z',
            vpcId: mockVpc.vpcId,
            cidrBlock: '0.0.0.0/0'
        });
        jest.spyOn(aws_ec2_1.Vpc, 'fromLookup').mockReturnValue(mockVpc);
        jest.spyOn(aws_ec2_1.Subnet, 'fromSubnetId').mockReturnValue(mockSubnet);
        const rswVpcPropsProps = {
            vpcId: mockVpc.vpcId,
            albSubnetIds: [mockSubnet.subnetId],
            ecsSubnetIds: []
        };
        const rswVpc = new RSWVpc_1.RSWVpc(stack, 'TestRSWVpc', rswVpcPropsProps);
        expect(rswVpc.vpc.vpcId).toEqual(mockVpc.vpcId);
        expect(rswVpc.albSubnetSelection.subnets).toEqual([mockSubnet]);
        // No VPCs or Subnets should be in the template because we are taking existing resources
        template.resourceCountIs('AWS::EC2::VPC', 0);
        template.resourceCountIs('AWS::EC2::Subnet', 0);
    });
});
//# sourceMappingURL=RSWVpc.test.js.map