Skip to content

Commit

Permalink
Refactored tests (#159)
Browse files Browse the repository at this point in the history
* Refactor tests.

* Tweak build.

* Tweak build.

* More tests.

* Tweak build.

* Tweak build.

* Fix build.

* Fix build.

* Speed up build.

* Fix build.

* Remove extra dep.

* Investigate why 0.12 fails.

* Scripts.

* More tests.

* Upgrades

* Upgrades

* Update readme
  • Loading branch information
jmdobry authored and NimJay committed Nov 10, 2022
1 parent dc7b876 commit da1d0de
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 12 deletions.
23 changes: 11 additions & 12 deletions cloud-language/snippets/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"name": "cloud-natural-language-api-samples",
"version": "1.0.0",
"description": "Samples for using the Google Cloud Natural Language API.",
"repository": {
"type": "git",
"url": "git://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"main": "analyze.js",
"name": "nodejs-docs-samples-language",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha -R spec -t 120000 --require intelli-espower-loader ../test/_setup.js test/*.test.js",
"system-test": "mocha -R spec -t 120000 --require intelli-espower-loader ../system-test/_setup.js system-test/*.test.js"
},
"dependencies": {
"googleapis": "^11.0.0"
"googleapis": "^12.0.0"
},
"author": "Google, Inc.",
"license": "Apache-2.0"
"devDependencies": {
"mocha": "^2.5.3"
}
}
62 changes: 62 additions & 0 deletions cloud-language/snippets/system-test/analyze.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

var analyzeExample = require('../../language/analyze');

describe('language:analyze', function () {
it('should analyze sentiment in text', function (done) {
analyzeExample.main(
'sentiment',
'This gazinga pin is bad and it should feel bad',
function (err, result) {
assert(!err);
assert(result);
assert(result.documentSentiment);
assert(result.documentSentiment.polarity < 0);
done();
}
);
});
it('should analyze entities in text', function (done) {
analyzeExample.main(
'entities',
'Mark Twain is the author of a book called Tom Sawyer',
function (err, result) {
assert(!err);
assert(result);
assert(result.entities && result.entities.length);
assert(result.entities[0].name === 'Mark Twain');
assert(result.entities[0].type === 'PERSON');
done();
}
);
});
it('should analyze syntax in text', function (done) {
analyzeExample.main(
'syntax',
'Betty bought a bit of bitter butter. But she said, "This butter\'s ' +
'bitter! If I put it in my batter, it will make my batter bitter. If I ' +
'buy some better butter - better than this bitter butter - it will ' +
'make my batter better."',
function (err, result) {
assert(!err);
assert(result);
assert(result.sentences && result.sentences.length);
assert(result.tokens && result.tokens.length > 5);
done();
}
);
});
});
18 changes: 18 additions & 0 deletions cloud-language/snippets/test/analyze.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

describe('language:analyze', function () {
it('should be tested');
});

0 comments on commit da1d0de

Please sign in to comment.