Skip to content

Commit

Permalink
refactor: modernize the sample tests (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Dec 26, 2018
1 parent 23065d3 commit c33d3fc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/google-cloud-texttospeech/samples/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
rules:
no-console: off
node/no-missing-require: off
9 changes: 6 additions & 3 deletions packages/google-cloud-texttospeech/samples/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
{
"name": "nodejs-docs-samples-text-to-speech",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": "googleapis/nodejs-text-to-speech",
"files": [
"*.js"
],
"engines": {
"node": ">=8"
},
"scripts": {
"test": "mocha system-test/*.test.js --timeout=600000"
"test": "mocha --timeout=60000"
},
"dependencies": {
"@google-cloud/text-to-speech": "^0.4.0",
"yargs": "^12.0.0"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"chai": "^4.2.0",
"execa": "^1.0.0",
"mocha": "^5.2.0"
},
"optionalDependencies": {
Expand Down
39 changes: 39 additions & 0 deletions packages/google-cloud-texttospeech/samples/test/quickstart.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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';

const fs = require('fs');
const {assert} = require('chai');
const execa = require('execa');

const outputFile = 'output.mp3';

describe('quickstart', () => {
after(() => {
try {
fs.unlinkSync(outputFile);
} catch (err) {
// Ignore error
}
});

it('should synthesize speech to local mp3 file', async () => {
assert.strictEqual(fs.existsSync(outputFile), false);
const {stdout} = await execa.shell('node quickstart');
assert.match(stdout, /Audio content written to file: output.mp3/);
assert.ok(fs.existsSync(outputFile));
});
});

0 comments on commit c33d3fc

Please sign in to comment.