Skip to content

Commit

Permalink
Update dependencies + fix a few tests (#448)
Browse files Browse the repository at this point in the history
* Add semistandard as a devDependency

* Fix storage tests

* Fix language tests

* Update (some) dependencies

* Fix language slackbot tests
  • Loading branch information
Ace Nassri authored Aug 5, 2017
1 parent b2c6f6c commit 659ea87
Show file tree
Hide file tree
Showing 8 changed files with 1,067 additions and 1,236 deletions.
8 changes: 4 additions & 4 deletions cloud-language/snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
},
"dependencies": {
"@google-cloud/language": "0.11.0",
"@google-cloud/storage": "1.1.1",
"@google-cloud/storage": "1.2.1",
"yargs": "8.0.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.4.15",
"ava": "0.19.1",
"@google-cloud/nodejs-repo-tools": "1.4.16",
"ava": "0.21.0",
"proxyquire": "1.8.0",
"sinon": "2.3.4"
"sinon": "3.0.0"
},
"cloud-repo-tools": {
"requiresKeyFile": true,
Expand Down
23 changes: 13 additions & 10 deletions cloud-language/snippets/slackbot/demo_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,17 @@ function analyzeEntities (text, ts) {
const language = Language();

// Instantiates a Document, representing the provided text
const document = language.document({
const document = {
// The document text, e.g. "Hello, world!"
content: text
});
content: text,
// The type of content to analyze
type: 'PLAIN_TEXT'
};

// Detects entities in the document
return document.detectEntities()
return language.analyzeEntities({ document: document })
.then((results) => {
const entities = results[0];

const entities = results[0].entities;
entities.forEach((entity) => {
const name = entity.name;
const type = entity.type;
Expand Down Expand Up @@ -210,13 +211,15 @@ function analyzeSentiment (text) {
const language = Language();

// Instantiates a Document, representing the provided text
const document = language.document({
const document = {
// The document text, e.g. "Hello, world!"
content: text
});
content: text,
// The type of content to analyze
type: 'PLAIN_TEXT'
};

// Detects the 'sentiment' of some text using the NL API
return document.detectSentiment()
return language.analyzeSentiment({ document: document })
.then((results) => {
const sentiment = results[0];

Expand Down
10 changes: 5 additions & 5 deletions cloud-language/snippets/slackbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"test": "npm run system-test"
},
"dependencies": {
"@google-cloud/language": "0.10.5",
"botkit": "0.5.4",
"@google-cloud/language": "0.11.0",
"botkit": "0.5.6",
"sqlite3": "3.1.8"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.4.15",
"ava": "0.19.1",
"@google-cloud/nodejs-repo-tools": "1.4.16",
"ava": "0.21.0",
"proxyquire": "1.8.0",
"sinon": "2.3.4"
"sinon": "3.0.0"
}
}
8 changes: 4 additions & 4 deletions cloud-language/snippets/slackbot/system-test/demo_bot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const tools = require(`@google-cloud/nodejs-repo-tools`);

const DB_PATH = path.join(__dirname, `../slackDB.db`);
const SLACK_TOKEN_PATH = path.join(__dirname, `../.token`);
const text = `President Obama is speaking at the White House.`;
const text = `President Obama is speaking at the White House. He is announcing an amazing new cookie recipe.`;

let db, controllerMock, botkitMock, botMock, program;

Expand Down Expand Up @@ -77,8 +77,8 @@ test.after.cb.always((t) => {
});

test.serial(`should analyze sentiment in text`, async (t) => {
const sentiment = await program.analyzeSentiment(text);
t.is(sentiment.score > 0, true);
const results = await program.analyzeSentiment(text);
t.is(results.documentSentiment.score > 0, true);
});

test.serial(`should analyze entities in text`, async (t) => {
Expand Down Expand Up @@ -119,7 +119,7 @@ test.cb.serial(`should reply to entities message`, (t) => {
try {
t.is(botMock.reply.callCount, 3);
t.deepEqual(botMock.reply.getCall(1).args, [message, `Top entities: `]);
t.deepEqual(botMock.reply.getCall(2).args, [message, `entity: *Obama*, type: PERSON, count: 1\nentity: *White House*, type: LOCATION, count: 1\n`]);
t.deepEqual(botMock.reply.getCall(2).args, [message, `entity: *Obama*, type: PERSON, count: 1\nentity: *White House*, type: LOCATION, count: 1\nentity: *cookie recipe*, type: WORK_OF_ART, count: 1\n`]);
t.end();
} catch (err) {
t.end(err);
Expand Down
Loading

0 comments on commit 659ea87

Please sign in to comment.