|
17 | 17 |
|
18 | 18 | 'use strict'; |
19 | 19 |
|
20 | | -const fs = require(`fs`); |
21 | | -const path = require(`path`); |
22 | | -const test = require(`ava`); |
23 | | -const tools = require(`@google-cloud/nodejs-repo-tools`); |
| 20 | +const fs = require('fs'); |
| 21 | +const path = require('path'); |
| 22 | +const assert = require('assert'); |
| 23 | +const tools = require('@google-cloud/nodejs-repo-tools'); |
24 | 24 |
|
25 | | -const cmd = `node audioProfile.js`; |
26 | | -const cwd = path.join(__dirname, `..`); |
27 | | -const text = `Hello Everybody! This is an Audio Profile Optimized Sound Byte.`; |
28 | | -const outputFile1 = `phonetest.mp3`; |
29 | | -const outputFile2 = `homeTheatreTest.mp3`; |
30 | | -const outputFile3 = `carAudioTest.mp3`; |
31 | | -const outputFile4 = `watchAudioTest.mp3`; |
| 25 | +const cmd = 'node audioProfile.js'; |
| 26 | +const cwd = path.join(__dirname, '..'); |
| 27 | +const text = 'Hello Everybody! This is an Audio Profile Optimized Sound Byte.'; |
| 28 | +const outputFile1 = 'phonetest.mp3'; |
| 29 | +const outputFile2 = 'homeTheatreTest.mp3'; |
| 30 | +const outputFile3 = 'carAudioTest.mp3'; |
| 31 | +const outputFile4 = 'watchAudioTest.mp3'; |
32 | 32 |
|
33 | | -test.before(tools.checkCredentials); |
| 33 | +before(tools.checkCredentials); |
34 | 34 |
|
35 | | -test.after(async () => { |
36 | | - await fs.unlink(outputFile1); |
37 | | - await fs.unlink(outputFile2); |
38 | | - await fs.unlink(outputFile3); |
39 | | - await fs.unlink(outputFile4); |
| 35 | +after(() => { |
| 36 | + function unlink(outputFile) { |
| 37 | + try { |
| 38 | + fs.unlinkSync(outputFile); |
| 39 | + } catch(err) { |
| 40 | + // Ignore error |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + [outputFile1, outputFile2, outputFile3, outputFile4].map(unlink); |
40 | 45 | }); |
41 | 46 |
|
42 | | -test(`Should synthesize Speech for Telephone Audio Profile`, async t => { |
43 | | - t.false(fs.existsSync(outputFile1)); |
| 47 | +it('Should synthesize Speech for Telephone Audio Profile', async () => { |
| 48 | + assert.strictEqual(fs.existsSync(outputFile1), false); |
44 | 49 | const output = await tools.runAsync( |
45 | | - `${cmd} synthesize '${text}' -f '${outputFile1}' -e telephony-class-application`, |
| 50 | + `${cmd} synthesize '${text}' -f ${outputFile1} -e telephony-class-application`, |
46 | 51 | cwd |
47 | 52 | ); |
48 | | - t.true(output.includes(`Audio content written to file: ${outputFile1}`)); |
49 | | - t.true(fs.existsSync(outputFile1)); |
| 53 | + assert.ok(output.includes(`Audio content written to file: ${outputFile1}`)); |
| 54 | + assert.ok(fs.existsSync(outputFile1)); |
50 | 55 | }); |
51 | 56 |
|
52 | | -test(`Should synthesize Speech for Home Theatre Audio Profile`, async t => { |
53 | | - t.false(fs.existsSync(outputFile2)); |
| 57 | +it('Should synthesize Speech for Home Theatre Audio Profile', async () => { |
| 58 | + assert.strictEqual(fs.existsSync(outputFile2), false); |
54 | 59 | const output = await tools.runAsync( |
55 | | - `${cmd} synthesize '${text}' -f '${outputFile2}' -e large-home-entertainment-class-device`, |
| 60 | + `${cmd} synthesize '${text}' -f ${outputFile2} -e large-home-entertainment-class-device`, |
56 | 61 | cwd |
57 | 62 | ); |
58 | | - t.true(output.includes(`Audio content written to file: ${outputFile2}`)); |
59 | | - t.true(fs.existsSync(outputFile2)); |
| 63 | + assert.ok(output.includes(`Audio content written to file: ${outputFile2}`)); |
| 64 | + assert.ok(fs.existsSync(outputFile2)); |
60 | 65 | }); |
61 | 66 |
|
62 | | -test(`Should synthesize Speech for Car Audio Audio Profile`, async t => { |
63 | | - t.false(fs.existsSync(outputFile3)); |
| 67 | +it('Should synthesize Speech for Car Audio Audio Profile', async () => { |
| 68 | + assert.strictEqual(fs.existsSync(outputFile3), false); |
64 | 69 | const output = await tools.runAsync( |
65 | | - `${cmd} synthesize '${text}' -f '${outputFile3}' -e large-automotive-class-device`, |
| 70 | + `${cmd} synthesize '${text}' -f ${outputFile3} -e large-automotive-class-device`, |
66 | 71 | cwd |
67 | 72 | ); |
68 | | - t.true(output.includes(`Audio content written to file: ${outputFile3}`)); |
69 | | - t.true(fs.existsSync(outputFile3)); |
| 73 | + assert.ok(output.includes(`Audio content written to file: ${outputFile3}`)); |
| 74 | + assert.ok(fs.existsSync(outputFile3)); |
70 | 75 | }); |
71 | 76 |
|
72 | | -test(`should synthesize Speech for Watch Audio Profile`, async t => { |
73 | | - t.false(fs.existsSync(outputFile4)); |
| 77 | +it('should synthesize Speech for Watch Audio Profile', async () => { |
| 78 | + assert.strictEqual(fs.existsSync(outputFile4), false); |
74 | 79 | const output = await tools.runAsync( |
75 | | - `${cmd} synthesize '${text}' -f '${outputFile4}' -e wearable-class-device`, |
| 80 | + `${cmd} synthesize '${text}' -f ${outputFile4} -e wearable-class-device`, |
76 | 81 | cwd |
77 | 82 | ); |
78 | | - t.true(output.includes(`Audio content written to file: ${outputFile4}`)); |
79 | | - t.true(fs.existsSync(outputFile4)); |
| 83 | + assert.ok(output.includes(`Audio content written to file: ${outputFile4}`)); |
| 84 | + assert.ok(fs.existsSync(outputFile4)); |
80 | 85 | }); |
0 commit comments