Skip to content

Commit 37f5076

Browse files
authored
Refactored tests (#159)
* Refactor tests. * Tweak build. * Tweak build. * More tests. * Tweak build. * Tweak build. * Fix build. * Fix build. * Speed up build. * Fix build. * Remove extra dep. * Investigate why 0.12 fails. * Scripts. * More tests. * Upgrades * Upgrades * Update readme
1 parent 9521b85 commit 37f5076

File tree

5 files changed

+115
-3
lines changed

5 files changed

+115
-3
lines changed

speech/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"name": "nodejs-docs-samples-speech",
3-
"description": "Node.js samples for Google Cloud Speech API.",
43
"version": "0.0.1",
54
"private": true,
65
"license": "Apache Version 2.0",
76
"author": "Google Inc.",
8-
"engines": {
9-
"node": ">=0.10.x"
7+
"scripts": {
8+
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../test/_setup.js test/*.test.js",
9+
"system-test": "mocha -R spec -t 120000 --require intelli-espower-loader ../system-test/_setup.js system-test/*.test.js"
1010
},
1111
"dependencies": {
1212
"async": "^1.5.2",
1313
"google-auto-auth": "^0.2.4",
1414
"google-proto-files": "^0.3.0",
1515
"googleapis": "^12.0.0",
1616
"grpc": "^0.15.0"
17+
},
18+
"devDependencies": {
19+
"mocha": "^2.5.3"
1720
}
1821
}

speech/system-test/recognize.test.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2016, Google, Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
'use strict';
15+
16+
var path = require('path');
17+
var recognizeExample = require('../recognize');
18+
19+
describe('speech:recognize', function () {
20+
it('should recognize speech in audio', function (done) {
21+
recognizeExample.main(
22+
path.join(__dirname, '../resources/audio.raw'),
23+
function (err, result) {
24+
assert(!err);
25+
assert(result);
26+
assert(Array.isArray(result.results));
27+
assert(result.results.length === 1);
28+
assert(result.results[0].alternatives);
29+
assert(console.log.calledWith('Got audio file!'));
30+
assert(console.log.calledWith('Analyzing speech...'));
31+
done();
32+
}
33+
);
34+
});
35+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2016, Google, Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
'use strict';
15+
16+
var path = require('path');
17+
var recognizeExample = require('../recognize_streaming');
18+
19+
describe('speech:recognize_streaming', function () {
20+
it('should recognize audio', function (done) {
21+
recognizeExample.main(
22+
path.join(__dirname, '../resources/audio.raw'),
23+
process.env.SPEECH_API_HOST || 'speech.googleapis.com',
24+
function (err, results) {
25+
assert(!err);
26+
assert(results);
27+
assert(results.length === 3);
28+
assert(results[0].results);
29+
assert(results[1].results);
30+
assert(results[2].results);
31+
assert(results[2].results.length === 1);
32+
assert(console.log.calledWith('Loading speech service...'));
33+
assert(console.log.calledWith('Analyzing speech...'));
34+
done();
35+
}
36+
);
37+
});
38+
});

speech/test/recognize.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016, Google, Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
'use strict';
15+
16+
describe('speech:recognize', function () {
17+
it('should be tested');
18+
});
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016, Google, Inc.
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
'use strict';
15+
16+
describe('speech:recognize_streaming', function () {
17+
it('should be tested');
18+
});

0 commit comments

Comments
 (0)