Skip to content

Commit 96adced

Browse files
vijay-qlogicJustinBeckwith
authored andcommitted
refactor: convert samples test from ava to mocha (#221)
1 parent 1a67943 commit 96adced

7 files changed

+205
-177
lines changed

speech/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"node": ">=8"
1010
},
1111
"scripts": {
12-
"test": "ava -T 20s --verbose system-test/*.test.js"
12+
"test": "mocha system-test/*.test.js --timeout 600000"
1313
},
1414
"dependencies": {
1515
"@google-cloud/speech": "^2.1.1",
@@ -19,7 +19,7 @@
1919
},
2020
"devDependencies": {
2121
"@google-cloud/nodejs-repo-tools": "^3.0.0",
22-
"ava": "^0.25.0",
22+
"mocha": "^5.2.0",
2323
"proxyquire": "^2.0.1",
2424
"sinon": "^7.0.0",
2525
"uuid": "^3.3.0"

speech/system-test/.eslintrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
env:
3+
mocha: true
24
rules:
35
node/no-unpublished-require: off
46
node/no-unsupported-features: off

speech/system-test/MicrophoneStream.test.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
'use strict';
1717

1818
const path = require(`path`);
19-
const test = require(`ava`);
19+
const assert = require(`assert`);
2020

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

25-
test(`MicrophoneStream.js Should load and display Yaaaarghs(!) correctly`, async t => {
26-
const output = await runAsync(`${cmd} --help`, cwd);
27-
t.true(
28-
output.includes('Streams audio input from microphone, translates to text')
29-
);
25+
describe(`MicrophoneStream`, () => {
26+
it(`MicrophoneStream.js Should load and display Yaaaarghs(!) correctly`, async () => {
27+
const output = await runAsync(`${cmd} --help`, cwd);
28+
assert.ok(
29+
output.includes('Streams audio input from microphone, translates to text')
30+
);
31+
});
3032
});

speech/system-test/betaFeatures.test.js

+74-60
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'use strict';
1919

2020
const path = require(`path`);
21-
const test = require(`ava`);
21+
const assert = require(`assert`);
2222

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

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

51-
test(`should run speech diarization on a local file`, async t => {
52-
const output = await runAsync(`${cmd} Diarization -f ${monoFilePath}`, cwd);
53-
t.true(output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`));
54-
});
55-
56-
test(`should run speech diarization on a GCS file`, async t => {
57-
const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd);
58-
t.true(output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`));
59-
});
60-
61-
test(`should run multi channel transcription on a local file`, async t => {
62-
const output = await runAsync(
63-
`${cmd} multiChannelTranscribe -f ${stereoFilePath}`,
64-
cwd
65-
);
66-
t.true(output.includes(`Channel Tag: 2`));
67-
});
68-
69-
test(`should run multi channel transcription on GCS file`, async t => {
70-
const output = await runAsync(
71-
`${cmd} multiChannelTranscribeGCS -u ${stereoUri}`,
72-
cwd
73-
);
74-
t.true(output.includes(`Channel Tag: 2`));
75-
});
76-
77-
test(`should transcribe multi-language on a local file`, async t => {
78-
const output = await runAsync(
79-
`${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`,
80-
cwd
81-
);
82-
t.true(output.includes(`Transcription: how are you doing estoy bien e tu`));
83-
});
84-
85-
test(`should transcribe multi-language on a GCS bucket`, async t => {
86-
const output = await runAsync(
87-
`${cmd} multiLanguageTranscribeGCS -u ${multiUri}`,
88-
cwd
89-
);
90-
t.true(output.includes(`Transcription: how are you doing estoy bien e tu`));
91-
});
92-
93-
test(`should run word Level Confience on a local file`, async t => {
94-
const output = await runAsync(
95-
`${cmd} wordLevelConfidence -f ${BrooklynFilePath}`
96-
);
97-
t.true(output.includes(`Transcription: how old is the Brooklyn Bridge`));
98-
t.true(/Confidence: \d\.\d/.test(output));
99-
});
100-
101-
test(`should run word level confidence on a GCS bucket`, async t => {
102-
const output = await runAsync(
103-
`${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`,
104-
cwd
105-
);
106-
t.true(
107-
output.includes(`Transcription: how old is the Brooklyn Bridge`) &&
108-
/Confidence: \d\.\d/.test(output)
109-
);
51+
describe(`BetaFeatures`, () => {
52+
53+
it(`should run speech diarization on a local file`, async () => {
54+
const output = await runAsync(
55+
`${cmd} Diarization -f ${monoFilePath}`,
56+
cwd
57+
);
58+
assert.ok(
59+
output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)
60+
);
61+
});
62+
63+
it(`should run speech diarization on a GCS file`, async () => {
64+
const output = await runAsync(`${cmd} DiarizationGCS -u ${monoUri}`, cwd);
65+
assert.ok(
66+
output.includes(`speakerTag: 1`) && output.includes(`speakerTag: 2`)
67+
);
68+
});
69+
70+
it(`should run multi channel transcription on a local file`, async () => {
71+
const output = await runAsync(
72+
`${cmd} multiChannelTranscribe -f ${stereoFilePath}`,
73+
cwd
74+
);
75+
assert.ok(output.includes(`Channel Tag: 2`));
76+
});
77+
78+
it(`should run multi channel transcription on GCS file`, async () => {
79+
const output = await runAsync(
80+
`${cmd} multiChannelTranscribeGCS -u ${stereoUri}`,
81+
cwd
82+
);
83+
assert.ok(output.includes(`Channel Tag: 2`));
84+
});
85+
86+
it(`should transcribe multi-language on a local file`, async () => {
87+
const output = await runAsync(
88+
`${cmd} multiLanguageTranscribe -f ${multiLanguageFile}`,
89+
cwd
90+
);
91+
assert.ok(output.includes(`Transcription: how are you doing estoy bien e tu`));
92+
});
93+
94+
it(`should transcribe multi-language on a GCS bucket`, async () => {
95+
const output = await runAsync(
96+
`${cmd} multiLanguageTranscribeGCS -u ${multiUri}`,
97+
cwd
98+
);
99+
assert.ok(
100+
output.includes(`Transcription: how are you doing estoy bien e tu`)
101+
);
102+
});
103+
104+
it(`should run word Level Confience on a local file`, async () => {
105+
const output = await runAsync(
106+
`${cmd} wordLevelConfidence -f ${BrooklynFilePath}`
107+
);
108+
assert.ok(
109+
output.includes(`Transcription: how old is the Brooklyn Bridge`)
110+
);
111+
assert.ok(/Confidence: \d\.\d/.test(output));
112+
});
113+
114+
it(`should run word level confidence on a GCS bucket`, async () => {
115+
const output = await runAsync(
116+
`${cmd} wordLevelConfidenceGCS -u ${brooklynUri}`,
117+
cwd
118+
);
119+
assert.ok(
120+
output.includes(`Transcription: how old is the Brooklyn Bridge`) &&
121+
/Confidence: \d\.\d/.test(output)
122+
);
123+
});
110124
});

speech/system-test/quickstart.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
'use strict';
1919

2020
const path = require(`path`);
21-
const test = require(`ava`);
21+
const assert = require(`assert`);
2222

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

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

29-
test.before(async () => {});
30-
31-
test(`should run quickstart`, async t => {
32-
const output = await runAsync(`${cmd}`, cwd);
33-
t.true(output.includes(`Transcription: ${text}`));
29+
describe(`Quickstart`, () => {
30+
it(`should run quickstart`, async () => {
31+
const output = await runAsync(`${cmd}`, cwd);
32+
assert.ok(output.includes(`Transcription: ${text}`));
33+
});
3434
});

0 commit comments

Comments
 (0)