"use strict";
const cdk_1 = require("@aws-cdk/cdk");
const lib_1 = require("../lib");
class TestApp {
    constructor() {
        this.app = new cdk_1.App();
        // tslint:disable-next-line:member-ordering
        this.stack = new cdk_1.Stack(this.app, 'MyStack');
    }
    synthesizeTemplate() {
        return this.app.synthesizeStack(this.stack.name).template;
    }
}
module.exports = {
    'default properties': {
        'add an SNS trigger to repository'(test) {
            const app = new TestApp();
            const props = {
                repositoryName: 'MyRepository'
            };
            const snsArn = 'arn:aws:sns:*:123456789012:my_topic';
            new lib_1.Repository(app.stack, 'MyRepository', props).notify(snsArn);
            const template = app.synthesizeTemplate();
            test.deepEqual(template, {
                Resources: {
                    MyRepository4C4BD5FC: {
                        Type: "AWS::CodeCommit::Repository",
                        Properties: {
                            RepositoryName: "MyRepository",
                            Triggers: [
                                {
                                    Events: [
                                        "all"
                                    ],
                                    DestinationArn: "arn:aws:sns:*:123456789012:my_topic",
                                    Name: "MyStack/MyRepository/arn:aws:sns:*:123456789012:my_topic"
                                }
                            ]
                        }
                    }
                }
            });
            test.done();
        },
        'fails when triggers have duplicate names'(test) {
            const app = new TestApp();
            const props = { repositoryName: 'MyRepository' };
            const myRepository = new lib_1.Repository(app.stack, 'MyRepository', props)
                .notify('myTrigger');
            test.throws(() => myRepository.notify('myTrigger'));
            test.done();
        }
    }
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5jb2RlY29tbWl0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsidGVzdC5jb2RlY29tbWl0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxzQ0FBMEM7QUFFMUMsZ0NBQXFEO0FBcURyRCxNQUFNLE9BQU87SUFBYjtRQUNxQixRQUFHLEdBQUcsSUFBSSxTQUFHLEVBQUUsQ0FBQztRQUNqQywyQ0FBMkM7UUFDM0IsVUFBSyxHQUFVLElBQUksV0FBSyxDQUFDLElBQUksQ0FBQyxHQUF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