/**
 *
 * Copyright 2018 Google LLC
 *
 * 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
 *
 *     https://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.
 *
 */

const assert = require('assert');
const execSync = require('child_process').execSync;
const commandExists = require('command-exists').sync;
const fs = require('fs');
const path = require('path');
const removeDirectory = require('./common.js').removeDirectory;
const GENERATED_CODE_PATH = require('./common.js').GENERATED_CODE_PATH;

describe('grpc-web generated code eval test (commonjs+dts)', function() {
  const genCodeCmd =
    'protoc -I=./test/protos foo.proto models.proto ' +
    '--js_out=import_style=commonjs:./test/generated ' +
    '--grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:./test/generated';

  before(function() {
    ['protoc', 'protoc-gen-grpc-web'].map(prog => {
      if (!commandExists(prog)) {
        assert.fail(`${prog} is not installed`);
      }
    });
  });

  beforeEach(function() {
    removeDirectory(path.resolve(__dirname, GENERATED_CODE_PATH));
    fs.mkdirSync(path.resolve(__dirname, GENERATED_CODE_PATH));
  });

  afterEach(function() {
    removeDirectory(path.resolve(__dirname, GENERATED_CODE_PATH));
  });

  it('should eval', function() {
    execSync(genCodeCmd);
    execSync(`npx gulp --gulpfile ./test/gulpfile.js gen-code-eval-test`);
  })
});

@@ -1802,12 +1802,938 @@
 );%0A  %7D)%0A%7D);%0A
+%0A%0Adescribe('grpc-web generated code eval test (typescript)', function() %7B%0A  const genTsCodePath = path.resolve(__dirname, './generated/FooServiceClientPb.ts');%0A%0A  const genCodeCmd =%0A    'protoc -I=./test/protos foo.proto models.proto ' +%0A    '--js_out=import_style=commonjs:./test/generated ' +%0A    '--grpc-web_out=import_style=typescript,mode=grpcwebtext:./test/generated';%0A%0A  before(function() %7B%0A    %5B'protoc', 'protoc-gen-grpc-web'%5D.map(prog =%3E %7B%0A      if (!commandExists(prog)) %7B%0A        assert.fail(%60$%7Bprog%7D is not installed%60);%0A      %7D%0A    %7D);%0A  %7D);%0A%0A  beforeEach(function() %7B%0A    removeDirectory(path.resolve(__dirname, GENERATED_CODE_PATH));%0A    fs.mkdirSync(path.resolve(__dirname, GENERATED_CODE_PATH));%0A  %7D);%0A%0A  afterEach(function() %7B%0A    removeDirectory(path.resolve(__dirname, GENERATED_CODE_PATH));%0A  %7D);%0A%0A  it('should eval', function() %7B%0A    execSync(genCodeCmd);%0A    execSync(%60tsc $%7BgenTsCodePath%7D%60);%0A  %7D);%0A%7D);%0A

Add eval test for TypeScript generated code