|
1 | 1 | /** |
2 | 2 | * Copyright 2017, Google, Inc. |
3 | | - * Licensed under the Apache License, Version 2.0 (the `License`); |
| 3 | + * Licensed under the Apache License, Version 2.0 (the 'License'); |
4 | 4 | * you may not use this file except in compliance with the License. |
5 | 5 | * You may obtain a copy of the License at |
6 | 6 | * |
7 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
8 | 8 | * |
9 | 9 | * Unless required by applicable law or agreed to in writing, software |
10 | | - * distributed under the License is distributed on an `AS IS` BASIS, |
| 10 | + * distributed under the License is distributed on an 'AS IS' BASIS, |
11 | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | * See the License for the specific language governing permissions and |
13 | 13 | * limitations under the License. |
|
17 | 17 |
|
18 | 18 | 'use strict'; |
19 | 19 |
|
20 | | -const path = require(`path`); |
21 | | -const test = require(`ava`); |
22 | | -const tools = require(`@google-cloud/nodejs-repo-tools`); |
| 20 | +const path = require('path'); |
| 21 | +const assert = require('assert'); |
| 22 | +const tools = require('@google-cloud/nodejs-repo-tools'); |
23 | 23 |
|
24 | | -const cmd = `node analyze.js`; |
25 | | -const cwd = path.join(__dirname, `..`); |
| 24 | +const cmd = 'node analyze.js'; |
| 25 | +const cwd = path.join(__dirname, '..'); |
26 | 26 |
|
27 | | -const url = `gs://nodejs-docs-samples-video/quickstart.mp4`; |
28 | | -const shortUrl = `gs://nodejs-docs-samples-video/quickstart_short.mp4`; |
29 | | -const file = `resources/cat.mp4`; |
| 27 | +const url = 'gs://nodejs-docs-samples-video/quickstart.mp4'; |
| 28 | +const shortUrl = 'gs://nodejs-docs-samples-video/quickstart_short.mp4'; |
| 29 | +const file = 'resources/cat.mp4'; |
30 | 30 |
|
31 | 31 | // analyze_labels_gcs (one scene) |
32 | | -test.serial(`should analyze labels in a GCS file with one scene`, async t => { |
| 32 | +it('should analyze labels in a GCS file with one scene', async () => { |
33 | 33 | const output = await tools.runAsync(`${cmd} labels-gcs ${shortUrl}`, cwd); |
34 | | - t.regex(output, /Label shirt occurs at:/); |
35 | | - t.regex(output, /Confidence: \d+\.\d+/); |
| 34 | + assert.strictEqual(new RegExp(/Label shirt occurs at:/).test(output), true); |
| 35 | + assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); |
36 | 36 | }); |
37 | 37 |
|
38 | 38 | // analyze_labels_gcs (multiple scenes) |
39 | | -test.serial( |
40 | | - `should analyze labels in a GCS file with multiple scenes`, |
41 | | - async t => { |
42 | | - const output = await tools.runAsync(`${cmd} labels-gcs ${url}`, cwd); |
43 | | - t.regex(output, /Label shirt occurs at:/); |
44 | | - t.regex(output, /Confidence: \d+\.\d+/); |
45 | | - } |
46 | | -); |
| 39 | +it('should analyze labels in a GCS file with multiple scenes', async () => { |
| 40 | + const output = await tools.runAsync(`${cmd} labels-gcs ${url}`, cwd); |
| 41 | + assert.strictEqual(new RegExp(/Label shirt occurs at:/).test(output), true); |
| 42 | + assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); |
| 43 | +}); |
47 | 44 |
|
48 | 45 | // analyze_labels_local |
49 | | -test.serial(`should analyze labels in a local file`, async t => { |
| 46 | +it('should analyze labels in a local file', async () => { |
50 | 47 | const output = await tools.runAsync(`${cmd} labels-file ${file}`, cwd); |
51 | | - t.regex(output, /Label whiskers occurs at:/); |
52 | | - t.regex(output, /Confidence: \d+\.\d+/); |
| 48 | + assert.strictEqual( |
| 49 | + new RegExp(/Label whiskers occurs at:/).test(output), |
| 50 | + true |
| 51 | + ); |
| 52 | + assert.strictEqual(new RegExp(/Confidence: \d+\.\d+/).test(output), true); |
53 | 53 | }); |
54 | 54 |
|
55 | 55 | // analyze_shots (multiple shots) |
56 | | -test.serial( |
57 | | - `should analyze shots in a GCS file with multiple shots`, |
58 | | - async t => { |
59 | | - const output = await tools.runAsync(`${cmd} shots ${url}`, cwd); |
60 | | - t.regex(output, /Scene 0 occurs from:/); |
61 | | - } |
62 | | -); |
| 56 | +it('should analyze shots in a GCS file with multiple shots', async () => { |
| 57 | + const output = await tools.runAsync(`${cmd} shots ${url}`, cwd); |
| 58 | + assert.strictEqual(new RegExp(/Scene 0 occurs from:/).test(output), true); |
| 59 | +}); |
63 | 60 |
|
64 | 61 | // analyze_shots (one shot) |
65 | | -test.serial(`should analyze shots in a GCS file with one shot`, async t => { |
| 62 | +it('should analyze shots in a GCS file with one shot', async () => { |
66 | 63 | const output = await tools.runAsync(`${cmd} shots ${shortUrl}`, cwd); |
67 | | - t.regex(output, /The entire video is one shot./); |
| 64 | + assert.strictEqual( |
| 65 | + new RegExp(/The entire video is one shot./).test(output), |
| 66 | + true |
| 67 | + ); |
68 | 68 | }); |
69 | 69 |
|
70 | 70 | // analyze_safe_search |
71 | | -test.serial(`should analyze safe search results in a GCS file`, async t => { |
| 71 | +it('should analyze safe search results in a GCS file', async () => { |
72 | 72 | const output = await tools.runAsync(`${cmd} safe-search ${url}`, cwd); |
73 | | - t.regex(output, /Time: \d+\.\d+s/); |
74 | | - t.regex(output, /Explicit annotation results:/); |
| 73 | + assert.strictEqual(new RegExp(/Time: \d+\.\d+s/).test(output), true); |
| 74 | + assert.strictEqual( |
| 75 | + new RegExp(/Explicit annotation results:/).test(output), |
| 76 | + true |
| 77 | + ); |
75 | 78 | }); |
76 | 79 |
|
77 | 80 | // analyze_video_transcription |
78 | | -test.serial( |
79 | | - `should analyze video transcription results in a GCS file`, |
80 | | - async t => { |
81 | | - const output = await tools.runAsync( |
82 | | - `${cmd} transcription ${shortUrl}`, |
83 | | - cwd |
84 | | - ); |
85 | | - t.regex(output, /over the pass/); |
86 | | - } |
87 | | -); |
| 81 | +it('should analyze video transcription results in a GCS file', async () => { |
| 82 | + const output = await tools.runAsync(`${cmd} transcription ${shortUrl}`, cwd); |
| 83 | + assert.strictEqual(new RegExp(/over the pass/).test(output), true); |
| 84 | +}); |
0 commit comments