Skip to content

Commit ec7743e

Browse files
angelcaamaliennae
andauthored
fix(test): resolve linting issues in translate_batch_translate_text.test.js (#4345)
* fix(test): resolve linting issues in translate_batch_translate_text * fix: fix formatting and syntax issues in translate_batch_translate_text.test.js * refactor: use await bucket.deleteFiles instead of for-loop --------- Co-authored-by: Jennifer Davis <sigje@google.com>
1 parent f711ad8 commit ec7743e

1 file changed

Lines changed: 23 additions & 26 deletions

File tree

translate/test/v3/translate_batch_translate_text.test.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,29 @@ describe(REGION_TAG, () => {
6161
console.error(error);
6262
}
6363
});
64-
}),
65-
it('should batch translate the input text', async function () {
66-
this.retries(3);
67-
const projectId = await translationClient.getProjectId();
68-
await clearBucket(projectId, storage, bucketUuid);
69-
const inputUri = 'gs://cloud-samples-data/translation/text.txt';
64+
});
7065

71-
const outputUri = `gs://${projectId}/${bucketName}`;
72-
const output = execSync(
73-
`node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}`
74-
);
75-
assert.match(output, /Total Characters: 13/);
76-
assert.match(output, /Translated Characters: 13/);
77-
}),
78-
// Delete the folder from GCS for cleanup
79-
after(async () => {
80-
const projectId = await translationClient.getProjectId();
81-
const options = {
82-
prefix: `translation-${bucketUuid}`,
83-
};
66+
it('should batch translate the input text', async function () {
67+
this.retries(3);
68+
const projectId = await translationClient.getProjectId();
69+
await clearBucket(projectId, storage, bucketUuid);
70+
const inputUri = 'gs://cloud-samples-data/translation/text.txt';
71+
72+
const outputUri = `gs://${projectId}/${bucketName}`;
73+
const output = execSync(
74+
`node v3/${REGION_TAG}.js ${projectId} ${location} ${inputUri} ${outputUri}`
75+
);
76+
assert.match(output, /Total Characters: 13/);
77+
assert.match(output, /Translated Characters: 13/);
78+
});
79+
// Delete the folder from GCS for cleanup
80+
after(async () => {
81+
const projectId = await translationClient.getProjectId();
82+
const options = {
83+
prefix: `translation-${bucketUuid}`,
84+
};
8485

85-
const bucket = await storage.bucket(projectId);
86-
const [files] = await bucket.getFiles(options);
87-
const length = files.length;
88-
if (length > 0) {
89-
await Promise.all(files.map(file => file.delete()));
90-
}
91-
});
86+
const bucket = await storage.bucket(projectId);
87+
await bucket.deleteFiles(options);
88+
});
9289
});

0 commit comments

Comments
 (0)