File tree Expand file tree Collapse file tree
packages/google-cloud-language/samples Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11---
22rules :
33 no-console : off
4+ node/no-missing-require : off
Original file line number Diff line number Diff line change 1212 " resources"
1313 ],
1414 "scripts" : {
15- "test" : " mocha"
15+ "test" : " mocha --timeout 60000 "
1616 },
1717 "dependencies" : {
1818 "@google-cloud/automl" : " ^0.1.1" ,
2222 "yargs" : " ^12.0.0"
2323 },
2424 "devDependencies" : {
25- "@google-cloud/nodejs-repo-tools" : " ^3.0.0" ,
25+ "chai" : " ^4.2.0" ,
26+ "execa" : " ^1.0.0" ,
2627 "mocha" : " ^5.2.0" ,
2728 "uuid" : " ^3.2.1"
2829 }
Original file line number Diff line number Diff line change 1616'use strict' ;
1717
1818// [START language_quickstart]
19- async function main ( ) {
19+ async function quickstart ( ) {
2020 // Imports the Google Cloud client library
2121 const language = require ( '@google-cloud/language' ) ;
2222
@@ -39,6 +39,6 @@ async function main() {
3939 console . log ( `Sentiment score: ${ sentiment . score } ` ) ;
4040 console . log ( `Sentiment magnitude: ${ sentiment . magnitude } ` ) ;
4141}
42-
43- main ( ) . catch ( console . error ) ;
4442// [END language_quickstart]
43+
44+ quickstart ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1515
1616'use strict' ;
1717
18- const path = require ( `path` ) ;
19- const assert = require ( 'assert' ) ;
20- const tools = require ( `@google-cloud/nodejs-repo-tools` ) ;
18+ const { assert} = require ( 'chai' ) ;
19+ const execa = require ( 'execa' ) ;
2120
22- const cmd = `node quickstart.js` ;
23- const cwd = path . join ( __dirname , `..` ) ;
24-
25- beforeEach ( async ( ) => tools . stubConsole ) ;
26- afterEach ( async ( ) => tools . restoreConsole ) ;
27-
28- it ( `should analyze sentiment in text` , async ( ) => {
29- const output = await tools . runAsync ( cmd , cwd ) ;
30- assert ( RegExp ( 'Text: Hello, world!' ) . test ( output ) ) ;
31- assert ( RegExp ( 'Sentiment score: ' ) . test ( output ) ) ;
32- assert ( RegExp ( 'Sentiment magnitude: ' ) . test ( output ) ) ;
21+ describe ( 'quickstart' , ( ) => {
22+ it ( 'should analyze sentiment in text' , async ( ) => {
23+ const { stdout} = await execa . shell ( 'node quickstart.js' ) ;
24+ assert ( stdout , / T e x t : H e l l o , w o r l d ! / ) ;
25+ assert ( stdout , / S e n t i m e n t s c o r e : / ) ;
26+ assert ( stdout , / S e n t i m e n t m a g n i t u d e : / ) ;
27+ } ) ;
3328} ) ;
You can’t perform that action at this time.
0 commit comments