@@ -40,15 +40,15 @@ describe('getRawProcessList', () => {
4040
4141 it ( 'should return a list containing this process' , ( done ) => {
4242 native . getProcessList ( ( list ) => {
43- assert . notStrictEqual ( list . find ( p => p . pid === process . pid ) , undefined ) ;
43+ assert . notStrictEqual ( list ? .find ( p => p . pid === process . pid ) , undefined ) ;
4444 done ( ) ;
4545 } , 0 ) ;
4646 } ) ;
4747
4848 it ( 'should handle multiple calls gracefully' , ( done ) => {
4949 let counter = 0 ;
5050 const callback = ( list ) => {
51- assert . notStrictEqual ( list . find ( p => p . pid === process . pid ) , undefined ) ;
51+ assert . notStrictEqual ( list ? .find ( p => p . pid === process . pid ) , undefined ) ;
5252 if ( ++ counter === 2 ) {
5353 done ( ) ;
5454 }
@@ -60,11 +60,11 @@ describe('getRawProcessList', () => {
6060 it ( 'should return memory information only when the flag is set' , ( done ) => {
6161 // Memory should be undefined when flag is not set
6262 native . getProcessList ( ( list ) => {
63- assert . strictEqual ( list . every ( p => p . memory === undefined ) , true ) ;
63+ assert . strictEqual ( list ? .every ( p => p . memory === undefined ) , true ) ;
6464
6565 // Memory should be a number when flag is set
6666 native . getProcessList ( ( list ) => {
67- assert . strictEqual ( list . some ( p => p . memory > 0 ) , true ) ;
67+ assert . strictEqual ( list ? .some ( p => p . memory > 0 ) , true ) ;
6868 done ( ) ;
6969 } , ProcessDataFlag . Memory ) ;
7070 } , ProcessDataFlag . None ) ;
@@ -73,11 +73,11 @@ describe('getRawProcessList', () => {
7373 it ( 'should return command line information only when the flag is set' , ( done ) => {
7474 // commandLine should be undefined when flag is not set
7575 native . getProcessList ( ( list ) => {
76- assert . strictEqual ( list . every ( p => p . commandLine === undefined ) , true ) ;
76+ assert . strictEqual ( list ? .every ( p => p . commandLine === undefined ) , true ) ;
7777
7878 // commandLine should be a string when flag is set
7979 native . getProcessList ( ( list ) => {
80- assert . strictEqual ( list . every ( p => typeof p . commandLine === 'string' ) , true ) ;
80+ assert . strictEqual ( list ? .every ( p => typeof p . commandLine === 'string' ) , true ) ;
8181 done ( ) ;
8282 } , ProcessDataFlag . CommandLine ) ;
8383 } , ProcessDataFlag . None ) ;
@@ -99,34 +99,34 @@ describe('getProcessList', () => {
9999
100100 it ( 'should return a list containing this process' , ( done ) => {
101101 getProcessList ( process . pid , ( list ) => {
102- assert . strictEqual ( list . length , 1 ) ;
103- assert . strictEqual ( list [ 0 ] . name , 'node.exe' ) ;
104- assert . strictEqual ( list [ 0 ] . pid , process . pid ) ;
105- assert . strictEqual ( list [ 0 ] . memory , undefined ) ;
106- assert . strictEqual ( list [ 0 ] . commandLine , undefined ) ;
102+ assert . strictEqual ( list ? .length , 1 ) ;
103+ assert . strictEqual ( list ! [ 0 ] . name , 'node.exe' ) ;
104+ assert . strictEqual ( list ! [ 0 ] . pid , process . pid ) ;
105+ assert . strictEqual ( list ! [ 0 ] . memory , undefined ) ;
106+ assert . strictEqual ( list ! [ 0 ] . commandLine , undefined ) ;
107107 done ( ) ;
108108 } ) ;
109109 } ) ;
110110
111111 it ( 'should return a list containing this process\'s memory if the flag is set' , done => {
112112 getProcessList ( process . pid , ( list ) => {
113- assert . strictEqual ( list . length , 1 ) ;
114- assert . strictEqual ( list [ 0 ] . name , 'node.exe' ) ;
115- assert . strictEqual ( list [ 0 ] . pid , process . pid ) ;
116- assert . strictEqual ( typeof list [ 0 ] . memory , 'number' ) ;
113+ assert . strictEqual ( list ? .length , 1 ) ;
114+ assert . strictEqual ( list ! [ 0 ] . name , 'node.exe' ) ;
115+ assert . strictEqual ( list ! [ 0 ] . pid , process . pid ) ;
116+ assert . strictEqual ( typeof list ! [ 0 ] . memory , 'number' ) ;
117117 done ( ) ;
118118 } , ProcessDataFlag . Memory ) ;
119119 } ) ;
120120
121121 it ( 'should return command line information only if the flag is set' , ( done ) => {
122122 getProcessList ( process . pid , ( list ) => {
123- assert . strictEqual ( list . length , 1 ) ;
124- assert . strictEqual ( list [ 0 ] . name , 'node.exe' ) ;
125- assert . strictEqual ( list [ 0 ] . pid , process . pid ) ;
126- assert . strictEqual ( typeof list [ 0 ] . commandLine , 'string' ) ;
123+ assert . strictEqual ( list ? .length , 1 ) ;
124+ assert . strictEqual ( list ! [ 0 ] . name , 'node.exe' ) ;
125+ assert . strictEqual ( list ! [ 0 ] . pid , process . pid ) ;
126+ assert . strictEqual ( typeof list ! [ 0 ] . commandLine , 'string' ) ;
127127 // CommandLine is "<path to node> <path to mocha> lib/test.js"
128- assert . strictEqual ( list [ 0 ] . commandLine . indexOf ( 'mocha' ) > 0 , true ) ;
129- assert . strictEqual ( list [ 0 ] . commandLine . indexOf ( 'lib/test.js' ) > 0 , true ) ;
128+ assert . strictEqual ( list ! [ 0 ] . commandLine ! . indexOf ( 'mocha' ) > 0 , true ) ;
129+ assert . strictEqual ( list ! [ 0 ] . commandLine ! . indexOf ( 'lib/test.js' ) > 0 , true ) ;
130130 done ( ) ;
131131 } , ProcessDataFlag . CommandLine ) ;
132132 } ) ;
@@ -136,7 +136,7 @@ describe('getProcessList', () => {
136136 pollUntil ( ( ) => {
137137 return new Promise ( ( resolve ) => {
138138 getProcessList ( process . pid , ( list ) => {
139- resolve ( list . length === 2 && list [ 0 ] . pid === process . pid && list [ 1 ] . pid === cps [ 0 ] . pid ) ;
139+ resolve ( list ? .length === 2 && list ! [ 0 ] . pid === process . pid && list [ 1 ] . pid === cps [ 0 ] . pid ) ;
140140 } ) ;
141141 } ) ;
142142 } , ( ) => done ( ) , 20 , 500 ) ;
@@ -148,11 +148,11 @@ describe('getProcessCpuUsage', () => {
148148 it ( 'should get process cpu usage' , ( done ) => {
149149 getProcessCpuUsage ( [ { pid : process . pid , ppid : process . ppid , name : 'node.exe' } ] , ( annotatedList ) => {
150150 assert . strictEqual ( annotatedList . length , 1 ) ;
151- assert . strictEqual ( annotatedList [ 0 ] . name , 'node.exe' ) ;
152- assert . strictEqual ( annotatedList [ 0 ] . pid , process . pid ) ;
153- assert . strictEqual ( annotatedList [ 0 ] . memory , undefined ) ;
154- assert . strictEqual ( typeof annotatedList [ 0 ] . cpu , 'number' ) ;
155- assert . strictEqual ( 0 <= annotatedList [ 0 ] . cpu && annotatedList [ 0 ] . cpu <= 100 , true ) ;
151+ assert . strictEqual ( annotatedList ! [ 0 ] . name , 'node.exe' ) ;
152+ assert . strictEqual ( annotatedList ! [ 0 ] . pid , process . pid ) ;
153+ assert . strictEqual ( annotatedList ! [ 0 ] . memory , undefined ) ;
154+ assert . strictEqual ( typeof annotatedList ! [ 0 ] . cpu , 'number' ) ;
155+ assert . strictEqual ( 0 <= annotatedList ! [ 0 ] . cpu ! && annotatedList ! [ 0 ] . cpu ! <= 100 , true ) ;
156156 done ( ) ;
157157 } ) ;
158158 } ) ;
@@ -162,7 +162,7 @@ describe('getProcessCpuUsage', () => {
162162
163163 let counter = 0 ;
164164 const callback = ( list ) => {
165- assert . notStrictEqual ( list . find ( p => p . pid === process . pid ) , undefined ) ;
165+ assert . notStrictEqual ( list ? .find ( p => p . pid === process . pid ) , undefined ) ;
166166 if ( ++ counter === 2 ) {
167167 done ( ) ;
168168 }
@@ -187,31 +187,31 @@ describe('getProcessTree', () => {
187187
188188 it ( 'should return a tree containing this process' , done => {
189189 getProcessTree ( process . pid , ( tree ) => {
190- assert . strictEqual ( tree . name , 'node.exe' ) ;
191- assert . strictEqual ( tree . pid , process . pid ) ;
192- assert . strictEqual ( tree . memory , undefined ) ;
193- assert . strictEqual ( tree . commandLine , undefined ) ;
194- assert . strictEqual ( tree . children . length , 0 ) ;
190+ assert . strictEqual ( tree ! . name , 'node.exe' ) ;
191+ assert . strictEqual ( tree ! . pid , process . pid ) ;
192+ assert . strictEqual ( tree ! . memory , undefined ) ;
193+ assert . strictEqual ( tree ! . commandLine , undefined ) ;
194+ assert . strictEqual ( tree ! . children . length , 0 ) ;
195195 done ( ) ;
196196 } ) ;
197197 } ) ;
198198
199199 it ( 'should return a tree containing this process\'s memory if the flag is set' , done => {
200200 getProcessTree ( process . pid , ( tree ) => {
201- assert . strictEqual ( tree . name , 'node.exe' ) ;
202- assert . strictEqual ( tree . pid , process . pid ) ;
203- assert . notStrictEqual ( tree . memory , undefined ) ;
204- assert . strictEqual ( tree . children . length , 0 ) ;
201+ assert . strictEqual ( tree ! . name , 'node.exe' ) ;
202+ assert . strictEqual ( tree ! . pid , process . pid ) ;
203+ assert . notStrictEqual ( tree ! . memory , undefined ) ;
204+ assert . strictEqual ( tree ! . children . length , 0 ) ;
205205 done ( ) ;
206206 } , ProcessDataFlag . Memory ) ;
207207 } ) ;
208208
209209 it ( 'should return a tree containing this process\'s command line if the flag is set' , done => {
210210 getProcessTree ( process . pid , ( tree ) => {
211- assert . strictEqual ( tree . name , 'node.exe' ) ;
212- assert . strictEqual ( tree . pid , process . pid ) ;
213- assert . strictEqual ( typeof tree . commandLine , 'string' ) ;
214- assert . strictEqual ( tree . children . length , 0 ) ;
211+ assert . strictEqual ( tree ! . name , 'node.exe' ) ;
212+ assert . strictEqual ( tree ! . pid , process . pid ) ;
213+ assert . strictEqual ( typeof tree ! . commandLine , 'string' ) ;
214+ assert . strictEqual ( tree ! . children . length , 0 ) ;
215215 done ( ) ;
216216 } , ProcessDataFlag . CommandLine ) ;
217217 } ) ;
@@ -221,7 +221,7 @@ describe('getProcessTree', () => {
221221 pollUntil ( ( ) => {
222222 return new Promise ( ( resolve ) => {
223223 getProcessTree ( process . pid , ( tree ) => {
224- resolve ( tree . children . length === 1 ) ;
224+ resolve ( tree ! . children . length === 1 ) ;
225225 } ) ;
226226 } ) ;
227227 } , ( ) => done ( ) , 20 , 500 ) ;
@@ -233,13 +233,13 @@ describe('getProcessTree', () => {
233233 pollUntil ( ( ) => {
234234 return new Promise ( ( resolve ) => {
235235 getProcessTree ( process . pid , ( tree ) => {
236- resolve ( tree . children . length === 2 &&
237- tree . children [ 0 ] . name === 'powershell.exe' &&
238- tree . children [ 0 ] . children . length === 0 &&
239- tree . children [ 1 ] . name === 'cmd.exe' &&
240- tree . children [ 1 ] . children &&
241- tree . children [ 1 ] . children . length === 1 &&
242- tree . children [ 1 ] . children [ 0 ] . name === 'powershell.exe' ) ;
236+ resolve ( tree ! . children . length === 2 &&
237+ tree ! . children [ 0 ] . name === 'powershell.exe' &&
238+ tree ! . children [ 0 ] . children . length === 0 &&
239+ tree ! . children [ 1 ] . name === 'cmd.exe' &&
240+ tree ! . children [ 1 ] . children &&
241+ tree ! . children [ 1 ] . children . length === 1 &&
242+ tree ! . children [ 1 ] . children [ 0 ] . name === 'powershell.exe' ) ;
243243 } ) ;
244244 } ) ;
245245 } , ( ) => done ( ) , 20 , 500 ) ;
@@ -251,14 +251,14 @@ describe('buildProcessTree', () => {
251251 const tree = buildProcessTree ( 0 , [
252252 { pid : 0 , ppid : 0 , name : '0' }
253253 ] , 3 ) ;
254- assert . strictEqual ( tree . pid , 0 ) ;
255- assert . strictEqual ( tree . children . length , 1 ) ;
256- assert . strictEqual ( tree . children [ 0 ] . pid , 0 ) ;
257- assert . strictEqual ( tree . children [ 0 ] . children . length , 1 ) ;
258- assert . strictEqual ( tree . children [ 0 ] . children [ 0 ] . pid , 0 ) ;
259- assert . strictEqual ( tree . children [ 0 ] . children [ 0 ] . children . length , 1 ) ;
260- assert . strictEqual ( tree . children [ 0 ] . children [ 0 ] . children [ 0 ] . pid , 0 ) ;
261- assert . strictEqual ( tree . children [ 0 ] . children [ 0 ] . children [ 0 ] . children . length , 0 ) ;
254+ assert . strictEqual ( tree ! . pid , 0 ) ;
255+ assert . strictEqual ( tree ! . children . length , 1 ) ;
256+ assert . strictEqual ( tree ! . children [ 0 ] . pid , 0 ) ;
257+ assert . strictEqual ( tree ! . children [ 0 ] . children . length , 1 ) ;
258+ assert . strictEqual ( tree ! . children [ 0 ] . children [ 0 ] . pid , 0 ) ;
259+ assert . strictEqual ( tree ! . children [ 0 ] . children [ 0 ] . children . length , 1 ) ;
260+ assert . strictEqual ( tree ! . children [ 0 ] . children [ 0 ] . children [ 0 ] . pid , 0 ) ;
261+ assert . strictEqual ( tree ! . children [ 0 ] . children [ 0 ] . children [ 0 ] . children . length , 0 ) ;
262262 } ) ;
263263} ) ;
264264
@@ -267,11 +267,11 @@ describe('filterProcessList', () => {
267267 const list = filterProcessList ( 0 , [
268268 { pid : 0 , ppid : 0 , name : '0' }
269269 ] , 3 ) ;
270- assert . strictEqual ( list . length , 4 ) ;
271- assert . strictEqual ( list [ 0 ] . pid , 0 ) ;
272- assert . strictEqual ( list [ 1 ] . pid , 0 ) ;
273- assert . strictEqual ( list [ 2 ] . pid , 0 ) ;
274- assert . strictEqual ( list [ 3 ] . pid , 0 ) ;
270+ assert . strictEqual ( list ? .length , 4 ) ;
271+ assert . strictEqual ( list ! [ 0 ] . pid , 0 ) ;
272+ assert . strictEqual ( list ! [ 1 ] . pid , 0 ) ;
273+ assert . strictEqual ( list ! [ 2 ] . pid , 0 ) ;
274+ assert . strictEqual ( list ! [ 3 ] . pid , 0 ) ;
275275 } ) ;
276276} ) ;
277277
@@ -293,11 +293,11 @@ describe('contextAware', () => {
293293 } ) ;
294294 const processListPromise : Promise < boolean > = new Promise ( resolve => {
295295 getProcessList ( process . pid , ( list ) => {
296- assert . strictEqual ( list . length >= 1 , true ) ;
297- assert . strictEqual ( list [ 0 ] . name , 'node.exe' ) ;
298- assert . strictEqual ( list [ 0 ] . pid , process . pid ) ;
299- assert . strictEqual ( list [ 0 ] . memory , undefined ) ;
300- assert . strictEqual ( list [ 0 ] . commandLine , undefined ) ;
296+ assert . strictEqual ( list ! . length >= 1 , true ) ;
297+ assert . strictEqual ( list ! [ 0 ] . name , 'node.exe' ) ;
298+ assert . strictEqual ( list ! [ 0 ] . pid , process . pid ) ;
299+ assert . strictEqual ( list ! [ 0 ] . memory , undefined ) ;
300+ assert . strictEqual ( list ! [ 0 ] . commandLine , undefined ) ;
301301 resolve ( true ) ;
302302 } ) ;
303303 } ) ;
@@ -327,17 +327,17 @@ describe('contextAware', () => {
327327 } ) ;
328328 } ) ;
329329 } ;
330- const workerPromises = [ ] ;
330+ const workerPromises : Promise < boolean > [ ] = [ ] ;
331331 for ( let i = 0 ; i < 50 ; i ++ ) {
332332 workerPromises . push ( makeWorkerPromise ( ) ) ;
333333 }
334334 const processListPromise : Promise < boolean > = new Promise ( resolve => {
335335 getProcessList ( process . pid , ( list ) => {
336- assert . strictEqual ( list . length >= 1 , true ) ;
337- assert . strictEqual ( list [ 0 ] . name , 'node.exe' ) ;
338- assert . strictEqual ( list [ 0 ] . pid , process . pid ) ;
339- assert . strictEqual ( list [ 0 ] . memory , undefined ) ;
340- assert . strictEqual ( list [ 0 ] . commandLine , undefined ) ;
336+ assert . strictEqual ( list ! . length >= 1 , true ) ;
337+ assert . strictEqual ( list ! [ 0 ] . name , 'node.exe' ) ;
338+ assert . strictEqual ( list ! [ 0 ] . pid , process . pid ) ;
339+ assert . strictEqual ( list ! [ 0 ] . memory , undefined ) ;
340+ assert . strictEqual ( list ! [ 0 ] . commandLine , undefined ) ;
341341 resolve ( true ) ;
342342 } ) ;
343343 } ) ;
0 commit comments