From 938aeeeb364db23fe14b2390eee65fc35d416f8f Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 30 Dec 2019 15:44:18 -0800 Subject: [PATCH] refactor: use explicit mocha imports (#505) --- vision/samples/.eslintrc.yml | 1 - vision/samples/setEndpoint.js | 8 ++++---- vision/samples/system-test/.eslintrc.yml | 3 --- .../system-test/async-batch-annotate-images.test.js | 1 + .../samples/system-test/batch-annotate-files-gcs.test.js | 1 + vision/samples/system-test/batch-annotate-files.test.js | 1 + vision/samples/system-test/detect.test.js | 1 + vision/samples/system-test/detect.v1p1beta1.test.js | 1 + vision/samples/system-test/detect.v1p3beta1.test.js | 1 + vision/samples/system-test/faceDetection.test.js | 1 + vision/samples/system-test/importProductSets.test.js | 1 + vision/samples/system-test/productSearch.test.js | 1 + vision/samples/system-test/productSets.test.js | 1 + vision/samples/system-test/products.test.js | 1 + vision/samples/system-test/quickstart.test.js | 1 + vision/samples/system-test/referenceImages.test.js | 1 + vision/samples/system-test/setEndpoint.test.js | 9 ++++----- vision/samples/system-test/similarProducts.test.js | 1 + vision/samples/system-test/textDetection.test.js | 1 + 19 files changed, 23 insertions(+), 13 deletions(-) delete mode 100644 vision/samples/system-test/.eslintrc.yml diff --git a/vision/samples/.eslintrc.yml b/vision/samples/.eslintrc.yml index 0aa37ac630..282535f55f 100644 --- a/vision/samples/.eslintrc.yml +++ b/vision/samples/.eslintrc.yml @@ -1,4 +1,3 @@ --- rules: no-console: off - node/no-missing-require: off diff --git a/vision/samples/setEndpoint.js b/vision/samples/setEndpoint.js index 42d90bd337..df3d33381f 100644 --- a/vision/samples/setEndpoint.js +++ b/vision/samples/setEndpoint.js @@ -26,10 +26,10 @@ async function setEndpoint() { const client = new vision.ImageAnnotatorClient(clientOptions); // [END vision_set_endpoint] - // Performs label detection on the image file - const [result] = await client.labelDetection('./resources/wakeupcat.jpg'); - const labels = result.labelAnnotations; - console.log('Labels:'); + // Performs text detection on the image file + const [result] = await client.textDetection('./resources/wakeupcat.jpg'); + const labels = result.textAnnotations; + console.log('Text:'); labels.forEach(label => console.log(label.description)); } diff --git a/vision/samples/system-test/.eslintrc.yml b/vision/samples/system-test/.eslintrc.yml deleted file mode 100644 index 6db2a46c53..0000000000 --- a/vision/samples/system-test/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -env: - mocha: true diff --git a/vision/samples/system-test/async-batch-annotate-images.test.js b/vision/samples/system-test/async-batch-annotate-images.test.js index b5f7873c6d..130ff073c3 100644 --- a/vision/samples/system-test/async-batch-annotate-images.test.js +++ b/vision/samples/system-test/async-batch-annotate-images.test.js @@ -18,6 +18,7 @@ const path = require('path'); const {Storage} = require('@google-cloud/storage'); const cp = require('child_process'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const uuid = require('uuid'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/batch-annotate-files-gcs.test.js b/vision/samples/system-test/batch-annotate-files-gcs.test.js index db4862ba38..574899a767 100644 --- a/vision/samples/system-test/batch-annotate-files-gcs.test.js +++ b/vision/samples/system-test/batch-annotate-files-gcs.test.js @@ -18,6 +18,7 @@ const path = require('path'); const {Storage} = require('@google-cloud/storage'); const cp = require('child_process'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const uuid = require('uuid'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/batch-annotate-files.test.js b/vision/samples/system-test/batch-annotate-files.test.js index f69cd8df38..e5e89c1da9 100644 --- a/vision/samples/system-test/batch-annotate-files.test.js +++ b/vision/samples/system-test/batch-annotate-files.test.js @@ -18,6 +18,7 @@ const path = require('path'); const {Storage} = require('@google-cloud/storage'); const cp = require('child_process'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const uuid = require('uuid'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/detect.test.js b/vision/samples/system-test/detect.test.js index c5b3d791cf..6dd22bbebc 100644 --- a/vision/samples/system-test/detect.test.js +++ b/vision/samples/system-test/detect.test.js @@ -19,6 +19,7 @@ const {Storage} = require('@google-cloud/storage'); const cp = require('child_process'); const uuid = require('uuid'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const vision = require('@google-cloud/vision'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/detect.v1p1beta1.test.js b/vision/samples/system-test/detect.v1p1beta1.test.js index 555c403f5b..da75a7cf4a 100644 --- a/vision/samples/system-test/detect.v1p1beta1.test.js +++ b/vision/samples/system-test/detect.v1p1beta1.test.js @@ -17,6 +17,7 @@ const path = require('path'); const cp = require('child_process'); const {assert} = require('chai'); +const {describe, it} = require('mocha'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/detect.v1p3beta1.test.js b/vision/samples/system-test/detect.v1p3beta1.test.js index 62f4381bb6..719c3ce32d 100644 --- a/vision/samples/system-test/detect.v1p3beta1.test.js +++ b/vision/samples/system-test/detect.v1p3beta1.test.js @@ -18,6 +18,7 @@ const path = require('path'); const {Storage} = require('@google-cloud/storage'); const cp = require('child_process'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const uuid = require('uuid'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/faceDetection.test.js b/vision/samples/system-test/faceDetection.test.js index 7c610890f1..fdc0ef40ae 100644 --- a/vision/samples/system-test/faceDetection.test.js +++ b/vision/samples/system-test/faceDetection.test.js @@ -16,6 +16,7 @@ const path = require('path'); const {assert} = require('chai'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/importProductSets.test.js b/vision/samples/system-test/importProductSets.test.js index 0211005766..f1e4c49eaf 100644 --- a/vision/samples/system-test/importProductSets.test.js +++ b/vision/samples/system-test/importProductSets.test.js @@ -15,6 +15,7 @@ 'use strict'; const {assert} = require('chai'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/productSearch.test.js b/vision/samples/system-test/productSearch.test.js index 2701d0f7db..7a7026fbb0 100644 --- a/vision/samples/system-test/productSearch.test.js +++ b/vision/samples/system-test/productSearch.test.js @@ -17,6 +17,7 @@ const uuid = require('uuid'); const vision = require('@google-cloud/vision'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/productSets.test.js b/vision/samples/system-test/productSets.test.js index 4be1685453..b0641bf164 100644 --- a/vision/samples/system-test/productSets.test.js +++ b/vision/samples/system-test/productSets.test.js @@ -17,6 +17,7 @@ const uuid = require('uuid'); const vision = require('@google-cloud/vision'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/products.test.js b/vision/samples/system-test/products.test.js index 558fd04095..0bac129faa 100644 --- a/vision/samples/system-test/products.test.js +++ b/vision/samples/system-test/products.test.js @@ -17,6 +17,7 @@ const uuid = require('uuid'); const vision = require('@google-cloud/vision'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/quickstart.test.js b/vision/samples/system-test/quickstart.test.js index 7dc9d56f84..6ec63ec8d0 100644 --- a/vision/samples/system-test/quickstart.test.js +++ b/vision/samples/system-test/quickstart.test.js @@ -15,6 +15,7 @@ 'use strict'; const {assert} = require('chai'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/referenceImages.test.js b/vision/samples/system-test/referenceImages.test.js index d56925779e..c754954ea6 100644 --- a/vision/samples/system-test/referenceImages.test.js +++ b/vision/samples/system-test/referenceImages.test.js @@ -17,6 +17,7 @@ const uuid = require('uuid'); const vision = require('@google-cloud/vision'); const {assert} = require('chai'); +const {describe, it, before, after} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/vision/samples/system-test/setEndpoint.test.js b/vision/samples/system-test/setEndpoint.test.js index 3c7aa2a7c7..e823c5782e 100644 --- a/vision/samples/system-test/setEndpoint.test.js +++ b/vision/samples/system-test/setEndpoint.test.js @@ -15,14 +15,13 @@ 'use strict'; const {assert} = require('chai'); +const {describe, it} = require('mocha'); const cp = require('child_process'); - const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); -describe(`set endpoint for vision api call`, () => { - it(`should detect labels in a remote file from a pre-set api endpoint`, async () => { +describe('set endpoint for vision api call', () => { + it('should detect text in a remote file from a pre-set api endpoint', () => { const stdout = execSync('node setEndpoint.js'); - assert.match(stdout, /Labels:/); - assert.match(stdout, /cat/); + assert.match(stdout, /human/); }); }); diff --git a/vision/samples/system-test/similarProducts.test.js b/vision/samples/system-test/similarProducts.test.js index 9c30a422cc..dbdab3e0ad 100644 --- a/vision/samples/system-test/similarProducts.test.js +++ b/vision/samples/system-test/similarProducts.test.js @@ -16,6 +16,7 @@ const vision = require('@google-cloud/vision'); const {assert} = require('chai'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const path = require('path'); diff --git a/vision/samples/system-test/textDetection.test.js b/vision/samples/system-test/textDetection.test.js index f6e73c2d0e..1def0220e1 100644 --- a/vision/samples/system-test/textDetection.test.js +++ b/vision/samples/system-test/textDetection.test.js @@ -16,6 +16,7 @@ const path = require('path'); const {assert} = require('chai'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});