@@ -19,7 +19,7 @@ const fs = require(`fs`);
19
19
const path = require ( `path` ) ;
20
20
const { Storage} = require ( `@google-cloud/storage` ) ;
21
21
const storage = new Storage ( ) ;
22
- const test = require ( `ava ` ) ;
22
+ const assert = require ( `assert ` ) ;
23
23
const tools = require ( `@google-cloud/nodejs-repo-tools` ) ;
24
24
const uuid = require ( `uuid` ) ;
25
25
@@ -33,119 +33,119 @@ const localFilePath2 = path.join(__dirname, `../resources/${fileName2}`);
33
33
const text = fs . readFileSync ( localFilePath , 'utf-8' ) ;
34
34
const text2 = fs . readFileSync ( localFilePath2 , 'utf-8' ) ;
35
35
36
- test . before ( async ( ) => {
36
+ before ( async ( ) => {
37
37
tools . checkCredentials ( ) ;
38
38
const [ bucket ] = await storage . createBucket ( bucketName ) ;
39
39
await bucket . upload ( localFilePath ) ;
40
40
await bucket . upload ( localFilePath2 ) ;
41
41
} ) ;
42
42
43
- test . after . always ( async ( ) => {
43
+ after ( async ( ) => {
44
44
const bucket = storage . bucket ( bucketName ) ;
45
45
await bucket . deleteFiles ( { force : true } ) ;
46
46
await bucket . deleteFiles ( { force : true } ) ; // Try a second time...
47
47
await bucket . delete ( ) ;
48
48
} ) ;
49
49
50
- test . beforeEach ( tools . stubConsole ) ;
51
- test . afterEach . always ( tools . restoreConsole ) ;
50
+ beforeEach ( async ( ) => tools . stubConsole ) ;
51
+ afterEach ( async ( ) => tools . restoreConsole ) ;
52
52
53
- test ( `should analyze sentiment in text` , async t => {
53
+ it ( `should analyze sentiment in text` , async ( ) => {
54
54
const output = await tools . runAsync ( `${ cmd } sentiment-text "${ text } "` , cwd ) ;
55
- t . regex ( output , new RegExp ( `Document sentiment:` ) ) ;
56
- t . regex ( output , new RegExp ( `Sentence: ${ text } ` ) ) ;
57
- t . regex ( output , new RegExp ( `Score: 0` ) ) ;
58
- t . regex ( output , new RegExp ( `Magnitude: 0` ) ) ;
55
+ assert ( RegExp ( `Document sentiment:` ) . test ( output ) ) ;
56
+ assert ( RegExp ( `Sentence: ${ text } ` ) . test ( output ) ) ;
57
+ assert ( RegExp ( `Score: 0` ) . test ( output ) ) ;
58
+ assert ( RegExp ( `Magnitude: 0` ) . test ( output ) ) ;
59
59
} ) ;
60
60
61
- test ( `should analyze sentiment in a file` , async t => {
61
+ it ( `should analyze sentiment in a file` , async ( ) => {
62
62
const output = await tools . runAsync (
63
63
`${ cmd } sentiment-file ${ bucketName } ${ fileName } ` ,
64
64
cwd
65
65
) ;
66
- t . regex ( output , new RegExp ( `Document sentiment:` ) ) ;
67
- t . regex ( output , new RegExp ( `Sentence: ${ text } ` ) ) ;
68
- t . regex ( output , new RegExp ( `Score: 0` ) ) ;
69
- t . regex ( output , new RegExp ( `Magnitude: 0` ) ) ;
66
+ assert ( output , new RegExp ( `Document sentiment:` ) . test ( output ) ) ;
67
+ assert ( RegExp ( `Sentence: ${ text } ` ) . test ( output ) ) ;
68
+ assert ( RegExp ( `Score: 0` ) . test ( output ) ) ;
69
+ assert ( RegExp ( `Magnitude: 0` ) . test ( output ) ) ;
70
70
} ) ;
71
71
72
- test ( `should analyze entities in text` , async t => {
72
+ it ( `should analyze entities in text` , async ( ) => {
73
73
const output = await tools . runAsync ( `${ cmd } entities-text "${ text } "` , cwd ) ;
74
- t . regex ( output , new RegExp ( `Obama` ) ) ;
75
- t . regex ( output , new RegExp ( `Type: PERSON` ) ) ;
76
- t . regex ( output , new RegExp ( `White House` ) ) ;
77
- t . regex ( output , new RegExp ( `Type: LOCATION` ) ) ;
74
+ assert ( RegExp ( `Obama` ) . test ( output ) ) ;
75
+ assert ( RegExp ( `Type: PERSON` ) . test ( output ) ) ;
76
+ assert ( RegExp ( `White House` ) . test ( output ) ) ;
77
+ assert ( RegExp ( `Type: LOCATION` ) . test ( output ) ) ;
78
78
} ) ;
79
79
80
- test ( 'should analyze entities in a file' , async t => {
80
+ it ( 'should analyze entities in a file' , async ( ) => {
81
81
const output = await tools . runAsync (
82
82
`${ cmd } entities-file ${ bucketName } ${ fileName } ` ,
83
83
cwd
84
84
) ;
85
- t . regex ( output , new RegExp ( `Entities:` ) ) ;
86
- t . regex ( output , new RegExp ( `Obama` ) ) ;
87
- t . regex ( output , new RegExp ( `Type: PERSON` ) ) ;
88
- t . regex ( output , new RegExp ( `White House` ) ) ;
89
- t . regex ( output , new RegExp ( `Type: LOCATION` ) ) ;
85
+ assert ( RegExp ( `Entities:` ) . test ( output ) ) ;
86
+ assert ( RegExp ( `Obama` ) . test ( output ) ) ;
87
+ assert ( RegExp ( `Type: PERSON` ) . test ( output ) ) ;
88
+ assert ( RegExp ( `White House` ) . test ( output ) ) ;
89
+ assert ( RegExp ( `Type: LOCATION` ) . test ( output ) ) ;
90
90
} ) ;
91
91
92
- test ( `should analyze syntax in text` , async t => {
92
+ it ( `should analyze syntax in text` , async ( ) => {
93
93
const output = await tools . runAsync ( `${ cmd } syntax-text "${ text } "` , cwd ) ;
94
- t . regex ( output , new RegExp ( `Tokens:` ) ) ;
95
- t . regex ( output , new RegExp ( `NOUN:` ) ) ;
96
- t . regex ( output , new RegExp ( `President` ) ) ;
97
- t . regex ( output , new RegExp ( `Obama` ) ) ;
98
- t . regex ( output , new RegExp ( `Morphology:` ) ) ;
99
- t . regex ( output , new RegExp ( `tag: 'NOUN'` ) ) ;
94
+ assert ( RegExp ( `Tokens:` ) . test ( output ) ) ;
95
+ assert ( RegExp ( `NOUN:` ) . test ( output ) ) ;
96
+ assert ( RegExp ( `President` ) . test ( output ) ) ;
97
+ assert ( RegExp ( `Obama` ) . test ( output ) ) ;
98
+ assert ( RegExp ( `Morphology:` ) . test ( output ) ) ;
99
+ assert ( RegExp ( `tag: 'NOUN'` ) . test ( output ) ) ;
100
100
} ) ;
101
101
102
- test ( 'should analyze syntax in a file' , async t => {
102
+ it ( 'should analyze syntax in a file' , async ( ) => {
103
103
const output = await tools . runAsync (
104
104
`${ cmd } syntax-file ${ bucketName } ${ fileName } ` ,
105
105
cwd
106
106
) ;
107
- t . regex ( output , new RegExp ( `NOUN:` ) ) ;
108
- t . regex ( output , new RegExp ( `President` ) ) ;
109
- t . regex ( output , new RegExp ( `Obama` ) ) ;
110
- t . regex ( output , new RegExp ( `Morphology:` ) ) ;
111
- t . regex ( output , new RegExp ( `tag: 'NOUN'` ) ) ;
107
+ assert ( RegExp ( `NOUN:` ) . test ( output ) ) ;
108
+ assert ( RegExp ( `President` ) . test ( output ) ) ;
109
+ assert ( RegExp ( `Obama` ) . test ( output ) ) ;
110
+ assert ( RegExp ( `Morphology:` ) . test ( output ) ) ;
111
+ assert ( RegExp ( `tag: 'NOUN'` ) . test ( output ) ) ;
112
112
} ) ;
113
113
114
- test ( `should analyze entity sentiment in text` , async t => {
114
+ it ( `should analyze entity sentiment in text` , async ( ) => {
115
115
const output = await tools . runAsync (
116
116
`${ cmd } entity-sentiment-text "${ text } "` ,
117
117
cwd
118
118
) ;
119
- t . regex ( output , new RegExp ( `Entities and sentiments:` ) ) ;
120
- t . regex ( output , new RegExp ( `Obama` ) ) ;
121
- t . regex ( output , new RegExp ( `PERSON` ) ) ;
122
- t . regex ( output , new RegExp ( `Score: 0` ) ) ;
123
- t . regex ( output , new RegExp ( `Magnitude: 0` ) ) ;
119
+ assert ( RegExp ( `Entities and sentiments:` ) . test ( output ) ) ;
120
+ assert ( RegExp ( `Obama` ) . test ( output ) ) ;
121
+ assert ( RegExp ( `PERSON` ) . test ( output ) ) ;
122
+ assert ( RegExp ( `Score: 0` ) . test ( output ) ) ;
123
+ assert ( RegExp ( `Magnitude: 0` ) . test ( output ) ) ;
124
124
} ) ;
125
125
126
- test ( 'should analyze entity sentiment in a file' , async t => {
126
+ it ( 'should analyze entity sentiment in a file' , async ( ) => {
127
127
const output = await tools . runAsync (
128
128
`${ cmd } entity-sentiment-file ${ bucketName } ${ fileName } ` ,
129
129
cwd
130
130
) ;
131
- t . regex ( output , new RegExp ( `Entities and sentiments:` ) ) ;
132
- t . regex ( output , new RegExp ( `Obama` ) ) ;
133
- t . regex ( output , new RegExp ( `PERSON` ) ) ;
134
- t . regex ( output , new RegExp ( `Score: 0` ) ) ;
135
- t . regex ( output , new RegExp ( `Magnitude: 0` ) ) ;
131
+ assert ( RegExp ( `Entities and sentiments:` ) . test ( output ) ) ;
132
+ assert ( RegExp ( `Obama` ) . test ( output ) ) ;
133
+ assert ( RegExp ( `PERSON` ) . test ( output ) ) ;
134
+ assert ( RegExp ( `Score: 0` ) . test ( output ) ) ;
135
+ assert ( RegExp ( `Magnitude: 0` ) . test ( output ) ) ;
136
136
} ) ;
137
137
138
- test ( 'should classify text in a file' , async t => {
138
+ it ( 'should classify text in a file' , async ( ) => {
139
139
const output = await tools . runAsync (
140
140
`${ cmd } classify-file ${ bucketName } ${ fileName2 } ` ,
141
141
cwd
142
142
) ;
143
- t . regex ( output , new RegExp ( `Name:` ) ) ;
144
- t . regex ( output , new RegExp ( `Computers & Electronics` ) ) ;
143
+ assert ( RegExp ( `Name:` ) . test ( output ) ) ;
144
+ assert ( RegExp ( `Computers & Electronics` ) . test ( output ) ) ;
145
145
} ) ;
146
146
147
- test ( 'should classify text in text' , async t => {
147
+ it ( 'should classify text in text' , async ( ) => {
148
148
const output = await tools . runAsync ( `${ cmd } classify-text "${ text2 } "` , cwd ) ;
149
- t . regex ( output , new RegExp ( `Name:` ) ) ;
150
- t . regex ( output , new RegExp ( `Computers & Electronics` ) ) ;
149
+ assert ( RegExp ( `Name:` ) . test ( output ) ) ;
150
+ assert ( RegExp ( `Computers & Electronics` ) . test ( output ) ) ;
151
151
} ) ;
0 commit comments