Skip to content

Commit

Permalink
refactor: convert samples test from ava to mocha (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay-qlogic authored and JustinBeckwith committed Nov 17, 2018
1 parent 1a67943 commit 96adced
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 177 deletions.
4 changes: 2 additions & 2 deletions speech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"node": ">=8"
},
"scripts": {
"test": "ava -T 20s --verbose system-test/*.test.js"
"test": "mocha system-test/*.test.js --timeout 600000"
},
"dependencies": {
"@google-cloud/speech": "^2.1.1",
Expand All @@ -19,7 +19,7 @@
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"ava": "^0.25.0",
"mocha": "^5.2.0",
"proxyquire": "^2.0.1",
"sinon": "^7.0.0",
"uuid": "^3.3.0"
Expand Down
2 changes: 2 additions & 0 deletions speech/system-test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
env:
mocha: true
rules:
node/no-unpublished-require: off
node/no-unsupported-features: off
Expand Down
14 changes: 8 additions & 6 deletions speech/system-test/MicrophoneStream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
'use strict';

const path = require(`path`);
const test = require(`ava`);
const assert = require(`assert`);

const {runAsync} = require(`@google-cloud/nodejs-repo-tools`);
const cmd = `node MicrophoneStream.js`;
const cwd = path.join(__dirname, `..`);

test(`MicrophoneStream.js Should load and display Yaaaarghs(!) correctly`, async t => {
const output = await runAsync(`${cmd} --help`, cwd);
t.true(
output.includes('Streams audio input from microphone, translates to text')
);
describe(`MicrophoneStream`, () => {
it(`MicrophoneStream.js Should load and display Yaaaarghs(!) correctly`, async () => {
const output = await runAsync(`${cmd} --help`, cwd);
assert.ok(
output.includes('Streams audio input from microphone, translates to text')
);
});
});
134 changes: 74 additions & 60 deletions speech/system-test/betaFeatures.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'use strict';

const path = require(`path`);
const test = require(`ava`);
const assert = require(`assert`);

const {runAsync} = require(`@google-cloud/nodejs-repo-tools`);

Expand Down Expand Up @@ -48,63 +48,77 @@ const multiUri = `gs://nodejs-docs-samples/multi_mono.wav`;
const brooklynUri = `gs://cloud-samples-tests/speech/brooklyn.flac`;
const stereoUri = `gs://cloud-samples-tests/speech/commercial_stereo.wav`;

test(`should run speech diarization on a local file`, async t => {
const output = await runAsync(`${cmd} Diarization -f ${monoFilePath}`, cwd);
t.true(output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`));
});

test(`should run speech diarization on a GCS file`, async t => {
const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd);
t.true(output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`));
});

test(`should run multi channel transcription on a local file`, async t => {
const output = await runAsync(
`${cmd} multiChannelTranscribe -f ${stereoFilePath}`,
cwd
);
t.true(output.includes(`Channel Tag: 2`));
});

test(`should run multi channel transcription on GCS file`, async t => {
const output = await runAsync(
`${cmd} multiChannelTranscribeGCS -u ${stereoUri}`,
cwd
);
t.true(output.includes(`Channel Tag: 2`));
});

test(`should transcribe multi-language on a local file`, async t => {
const output = await runAsync(
`${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`,
cwd
);
t.true(output.includes(`Transcription: how are you doing estoy bien e tu`));
});

test(`should transcribe multi-language on a GCS bucket`, async t => {
const output = await runAsync(
`${cmd} multiLanguageTranscribeGCS -u ${multiUri}`,
cwd
);
t.true(output.includes(`Transcription: how are you doing estoy bien e tu`));
});

test(`should run word Level Confience on a local file`, async t => {
const output = await runAsync(
`${cmd} wordLevelConfidence -f ${BrooklynFilePath}`
);
t.true(output.includes(`Transcription: how old is the Brooklyn Bridge`));
t.true(/Confidence: \d\.\d/.test(output));
});

test(`should run word level confidence on a GCS bucket`, async t => {
const output = await runAsync(
`${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`,
cwd
);
t.true(
output.includes(`Transcription: how old is the Brooklyn Bridge`) &&
/Confidence: \d\.\d/.test(output)
);
describe(`BetaFeatures`, () => {

it(`should run speech diarization on a local file`, async () => {
const output = await runAsync(
`${cmd} Diarization -f ${monoFilePath}`,
cwd
);
assert.ok(
output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)
);
});

it(`should run speech diarization on a GCS file`, async () => {
const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd);
assert.ok(
output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)
);
});

it(`should run multi channel transcription on a local file`, async () => {
const output = await runAsync(
`${cmd} multiChannelTranscribe -f ${stereoFilePath}`,
cwd
);
assert.ok(output.includes(`Channel Tag: 2`));
});

it(`should run multi channel transcription on GCS file`, async () => {
const output = await runAsync(
`${cmd} multiChannelTranscribeGCS -u ${stereoUri}`,
cwd
);
assert.ok(output.includes(`Channel Tag: 2`));
});

it(`should transcribe multi-language on a local file`, async () => {
const output = await runAsync(
`${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`,
cwd
);
assert.ok(output.includes(`Transcription: how are you doing estoy bien e tu`));
});

it(`should transcribe multi-language on a GCS bucket`, async () => {
const output = await runAsync(
`${cmd} multiLanguageTranscribeGCS -u ${multiUri}`,
cwd
);
assert.ok(
output.includes(`Transcription: how are you doing estoy bien e tu`)
);
});

it(`should run word Level Confience on a local file`, async () => {
const output = await runAsync(
`${cmd} wordLevelConfidence -f ${BrooklynFilePath}`
);
assert.ok(
output.includes(`Transcription: how old is the Brooklyn Bridge`)
);
assert.ok(/Confidence: \d\.\d/.test(output));
});

it(`should run word level confidence on a GCS bucket`, async () => {
const output = await runAsync(
`${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`,
cwd
);
assert.ok(
output.includes(`Transcription: how old is the Brooklyn Bridge`) &&
/Confidence: \d\.\d/.test(output)
);
});
});
12 changes: 6 additions & 6 deletions speech/system-test/quickstart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
'use strict';

const path = require(`path`);
const test = require(`ava`);
const assert = require(`assert`);

const cmd = `node quickstart.js`;
const cwd = path.join(__dirname, `..`);
const text = `how old is the Brooklyn Bridge`;

const {runAsync} = require(`@google-cloud/nodejs-repo-tools`);

test.before(async () => {});

test(`should run quickstart`, async t => {
const output = await runAsync(`${cmd}`, cwd);
t.true(output.includes(`Transcription: ${text}`));
describe(`Quickstart`, () => {
it(`should run quickstart`, async () => {
const output = await runAsync(`${cmd}`, cwd);
assert.ok(output.includes(`Transcription: ${text}`));
});
});
Loading

0 comments on commit 96adced

Please sign in to comment.