-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: modernize the sample tests (#164)
- Loading branch information
1 parent
ca6e511
commit a9010d8
Showing
9 changed files
with
219 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
rules: | ||
no-console: off | ||
node/no-missing-require: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* Copyright 2018, 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 cmd = 'node audioProfile.js'; | ||
const exec = async cmd => { | ||
const res = await execa.shell(cmd); | ||
assert.isEmpty(res.stderr); | ||
return res.stdout; | ||
}; | ||
const text = 'Hello Everybody! This is an Audio Profile Optimized Sound Byte.'; | ||
const outputFile1 = 'phonetest.mp3'; | ||
const outputFile2 = 'homeTheatreTest.mp3'; | ||
const outputFile3 = 'carAudioTest.mp3'; | ||
const outputFile4 = 'watchAudioTest.mp3'; | ||
|
||
describe('audio profile', () => { | ||
after(() => { | ||
function unlink(outputFile) { | ||
try { | ||
fs.unlinkSync(outputFile); | ||
} catch (err) { | ||
// Ignore error | ||
} | ||
} | ||
[outputFile1, outputFile2, outputFile3, outputFile4].map(unlink); | ||
}); | ||
|
||
it('should synthesize Speech for Telephone Audio Profile', async () => { | ||
assert.strictEqual(fs.existsSync(outputFile1), false); | ||
const output = await exec( | ||
`${cmd} synthesize '${text}' -f ${outputFile1} -e telephony-class-application` | ||
); | ||
assert.match( | ||
output, | ||
new RegExp(`Audio content written to file: ${outputFile1}`) | ||
); | ||
assert.ok(fs.existsSync(outputFile1)); | ||
}); | ||
|
||
it('should synthesize Speech for Home Theatre Audio Profile', async () => { | ||
assert.strictEqual(fs.existsSync(outputFile2), false); | ||
const output = await exec( | ||
`${cmd} synthesize '${text}' -f ${outputFile2} -e large-home-entertainment-class-device` | ||
); | ||
assert.match( | ||
output, | ||
new RegExp(`Audio content written to file: ${outputFile2}`) | ||
); | ||
assert.ok(fs.existsSync(outputFile2)); | ||
}); | ||
|
||
it('should synthesize Speech for Car Audio Audio Profile', async () => { | ||
assert.strictEqual(fs.existsSync(outputFile3), false); | ||
const output = await exec( | ||
`${cmd} synthesize '${text}' -f ${outputFile3} -e large-automotive-class-device` | ||
); | ||
assert.match( | ||
output, | ||
new RegExp(`Audio content written to file: ${outputFile3}`) | ||
); | ||
assert.ok(fs.existsSync(outputFile3)); | ||
}); | ||
|
||
it('should synthesize Speech for Watch Audio Profile', async () => { | ||
assert.strictEqual(fs.existsSync(outputFile4), false); | ||
const output = await exec( | ||
`${cmd} synthesize '${text}' -f ${outputFile4} -e wearable-class-device` | ||
); | ||
assert.match( | ||
output, | ||
new RegExp(`Audio content written to file: ${outputFile4}`) | ||
); | ||
assert.ok(fs.existsSync(outputFile4)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.