Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
fix: ignore case in system test assertions (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Jan 27, 2019
1 parent 767cff5 commit 5460a85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Binary file added samples/resources/google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions samples/system-test/detect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const files = [
`city.jpg`,
'pdf-ocr.pdf',
'duck_and_truck.jpg',
'google.png',
].map(name => {
return {
name,
Expand Down Expand Up @@ -114,17 +115,17 @@ describe(`detect`, () => {
});

it(`should detect logos in a local file`, async () => {
const output = await exec(`${cmd} logos ${files[2].localPath}`);
const output = await exec(`${cmd} logos ${files[9].localPath}`);
assert.match(output, /Logos:/);
assert.match(output, /Google/);
assert.match(output, /google/);
});

it(`should detect logos in a remote file`, async () => {
const output = await exec(
`${cmd} logos-gcs ${bucketName} ${files[2].name}`
`${cmd} logos-gcs ${bucketName} ${files[9].name}`
);
assert.match(output, /Logos:/);
assert.match(output, /Google/);
assert.match(output, /google/);
});

it(`should detect properties in a local file`, async () => {
Expand Down
15 changes: 12 additions & 3 deletions system-test/vision.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,31 @@ describe('Vision', function() {
'https://upload.wikimedia.org/wikipedia/commons/5/51/Google.png';
return client.logoDetection(url).then(responses => {
const response = responses[0];
assert.deepStrictEqual(response.logoAnnotations[0].description, 'Google');
assert.strictEqual(
response.logoAnnotations[0].description.toLowerCase(),
'google'
);
});
});

it('should detect from a filename', () => {
return client.logoDetection(IMAGES.logo).then(responses => {
const response = responses[0];
assert.deepStrictEqual(response.logoAnnotations[0].description, 'Google');
assert.deepStrictEqual(
response.logoAnnotations[0].description.toLowerCase(),
'google'
);
});
});

it('should detect from a Buffer', () => {
const buffer = fs.readFileSync(IMAGES.logo);
return client.logoDetection(buffer).then(responses => {
const response = responses[0];
assert.deepStrictEqual(response.logoAnnotations[0].description, 'Google');
assert.deepStrictEqual(
response.logoAnnotations[0].description.toLowerCase(),
'google'
);
});
});

Expand Down

0 comments on commit 5460a85

Please sign in to comment.