"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**
 * Copyright 2017-2020 Plexus Interop Deutsche Bank AG
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var setup_1 = require("./setup");
var path = require("path");
var GenTsCommand_1 = require("../../src/commands/GenTsCommand");
describe('Typescript Client generation CLI', function () {
    it('Generates Client and messages definitions', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
        var testName, genCommand, outDir, _a, _b, _c;
        return tslib_1.__generator(this, function (_d) {
            switch (_d.label) {
                case 0:
                    testName = 'generated-ts-client';
                    genCommand = new GenTsCommand_1.GenTsCommand();
                    outDir = setup_1.prepareOutDir(testName);
                    return [4 /*yield*/, genCommand.action({
                            out: outDir,
                            baseDir: setup_1.getTestBaseDir(),
                            input: setup_1.getTestClientInput(),
                            namespace: 'plexus'
                        })];
                case 1:
                    _d.sent();
                    _a = expect;
                    return [4 /*yield*/, setup_1.filesEqual(path.join(outDir, 'GreetingClientGeneratedClient.ts'), path.join(setup_1.getApprovalsBaseDir(), 'generated-ts-client.approved.txt'))];
                case 2:
                    _a.apply(void 0, [_d.sent()]).toBeTruthy();
                    _b = expect;
                    return [4 /*yield*/, setup_1.filesEqual(path.join(outDir, 'plexus-messages.js'), path.join(setup_1.getApprovalsBaseDir(), 'generated-ts-messages.approved.txt'))];
                case 3:
                    _b.apply(void 0, [_d.sent()]).toBeTruthy();
                    _c = expect;
                    return [4 /*yield*/, setup_1.filesEqual(path.join(outDir, 'plexus-messages.d.ts'), path.join(setup_1.getApprovalsBaseDir(), 'generated-ts-definitions.approved.txt'))];
                case 4:
                    _c.apply(void 0, [_d.sent()]).toBeTruthy();
                    return [2 /*return*/];
            }
        });
    }); }, 15000);
    it('Handles different proto files', function () {
        var genCommand = new GenTsCommand_1.GenTsCommand();
        expect(genCommand.protoRegexp.test('src/authservice.proto')).toBeTruthy();
        expect(genCommand.protoRegexp.test('authservice.proto')).toBeTruthy();
        expect(genCommand.protoRegexp.test('AuthService_v1.proto')).toBeTruthy();
        expect(genCommand.protoRegexp.test('src/auth_service.proto')).toBeTruthy();
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR2V0VHNDb21tYW5kLnNwZWMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi90ZXN0cy9jb21tYW5kcy9HZXRUc0NvbW1hbmQuc3BlYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7QUFDSCxpQ0FBNkc7QUFDN0csMkJBQTZCO0FBQzdCLGdFQUErRDtBQUUvRCxRQUFRLENBQUMsa0NBQWtDLEVBQUU7SUFFekMsRUFBRSxDQUFDLDJDQUEyQyxFQUFFOzs7OztvQkFFdEMsUUFBUSxHQUFHLHFCQUFxQixDQUFDO29CQUNqQyxVQUFVLEdBQUcsSUFBSSwyQkFBWSxFQUFFLENBQUM7b0JBQ2hDLE1BQU0sR0FBRyxxQkFBYSxDQUFDLFFBQVEsQ0FBQyxDQUFDO29CQUV2QyxxQkFBTSxVQUFVLENBQUMsTUFBTSxDQUFDOzRCQUNwQixHQUFHLEVBQUUsTUFBTTs0QkFDWCxPQUFPLEVBQUUsc0JBQWMsRUFBRTs0QkFDekIsS0FBSyxFQUFFLDBCQUFrQixFQUFFOzRCQUMzQixTQUFTLEVBQUUsUUFBUTt5QkFDdEIsQ0FBQyxFQUFBOztvQkFMRixTQUtFLENBQUM7b0JBRUgsS0FBQSxNQUFNLENBQU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