Skip to content

Commit fa0fb90

Browse files
author
Ace Nassri
authored
chore(functions/ocr): fix newline-induced test flakes (GoogleCloudPlatform#2635)
* chore(functions/ocr): fix newline-induced test flakes * Fix lint
1 parent 443b0ac commit fa0fb90

3 files changed

Lines changed: 3 additions & 5 deletions

File tree

functions/ocr/app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const detectText = async (bucketName, filename) => {
5959
`gs://${bucketName}/${filename}`
6060
);
6161
const [annotation] = textDetections.textAnnotations;
62-
const text = annotation ? annotation.description : '';
62+
const text = annotation ? annotation.description.trim() : '';
6363
console.log('Extracted text from image:', text);
6464

6565
let [translateDetection] = await translate.detect(text);

functions/ocr/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@google-cloud/pubsub": "^2.1.0",
1919
"@google-cloud/storage": "^5.1.1",
2020
"@google-cloud/translate": "^6.0.0",
21-
"@google-cloud/vision": "^2.1.0"
21+
"@google-cloud/vision": "^2.4.0"
2222
},
2323
"devDependencies": {
2424
"mocha": "^9.0.0",

functions/ocr/app/test/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ describe('processImage', () => {
7070
assert.ok(
7171
console.log.calledWith(`Detected language "en" for ${filename}`)
7272
);
73-
assert.ok(
74-
console.log.calledWith('Extracted text from image:', `${text}\n`)
75-
);
73+
assert.ok(console.log.calledWith('Extracted text from image:', text));
7674
assert.ok(
7775
console.log.calledWith(`Detected language "en" for ${filename}`)
7876
);

0 commit comments

Comments
 (0)