{"size": 1364, "ext": "js", "max_stars_repo_path": "test/samples/nodejs/snippet/test/index.test.js", "max_stars_repo_name": "grant/nodejs-repo-tools", "max_stars_repo_stars_event_min_datetime": "2016-06-02T02:53:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-09T04:10:09.000Z", "max_issues_repo_path": "test/samples/nodejs/snippet/test/index.test.js", "max_issues_repo_name": "grant/nodejs-repo-tools", "max_issues_repo_issues_event_min_datetime": "2016-07-12T01:42:25.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-27T07:53:05.000Z", "max_forks_repo_path": "test/samples/nodejs/snippet/test/index.test.js", "max_forks_repo_name": "grant/nodejs-repo-tools", "max_forks_repo_forks_event_min_datetime": "2016-06-02T02:53:44.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-19T15:16:05.000Z"}
{"max_stars_count": 54, "max_issues_count": 197, "max_forks_count": 34, "avg_line_length": 29.652173913, "max_line_length": 75, "alphanum_fraction": 0.6671554252}
/**
 * Copyright 2017, Google, Inc.
 * 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.
 */

'use strict';

/* global before, describe, it */

var assert = require('assert');
var path = require('path');
// eslint-disable-next-line
var tools = require('../../../../../');
var translate = require('@google-cloud/translate')();

var cwd = path.join(__dirname, '..');
var cmd = 'node index.js';
var lang = 'ru';
var text = 'Hello, world!';

before(tools.checkCredentials);

describe('snippet', function() {
  it('should work', function() {
    return Promise.all([
      tools.runAsync(cmd, cwd),
      translate.translate(text, lang),
    ]).then(function(results) {
      var output = results[0];
      var translation = results[1][0];
      assert(output.includes('Text: ' + text));
      assert(output.includes('Translation: ' + translation));
    });
  });
});
