1
1
import { expect } from 'chai' ;
2
2
import request = require( 'request' ) ;
3
- import { ReadableStreamBuffer , WritableStreamBuffer } from 'stream-buffers' ;
4
3
import { anyFunction , anything , capture , instance , mock , reset , verify , when } from 'ts-mockito' ;
5
4
6
5
import { KubeConfig } from './config' ;
@@ -60,8 +59,10 @@ describe('Watch', () => {
60
59
path ,
61
60
{ } ,
62
61
( phase : string , obj : string ) => { } ,
63
- ( err : any ) => {
62
+ ( ) => {
64
63
doneCalled = true ;
64
+ } ,
65
+ ( err : any ) => {
65
66
doneErr = err ;
66
67
} ,
67
68
) ;
@@ -130,8 +131,10 @@ describe('Watch', () => {
130
131
receivedTypes . push ( phase ) ;
131
132
receivedObjects . push ( obj ) ;
132
133
} ,
133
- ( err : any ) => {
134
+ ( ) => {
134
135
doneCalled = true ;
136
+ } ,
137
+ ( err : any ) => {
135
138
doneErr = err ;
136
139
} ,
137
140
) ;
@@ -153,7 +156,7 @@ describe('Watch', () => {
153
156
doneCallback ( null , null , null ) ;
154
157
155
158
expect ( doneCalled ) . to . equal ( true ) ;
156
- expect ( doneErr ) . to . equal ( null ) ;
159
+ expect ( doneErr ) . to . be . undefined ;
157
160
158
161
const errIn = { error : 'err' } ;
159
162
doneCallback ( errIn , null , null ) ;
@@ -198,10 +201,8 @@ describe('Watch', () => {
198
201
receivedTypes . push ( phase ) ;
199
202
receivedObjects . push ( obj ) ;
200
203
} ,
201
- ( err : any ) => {
202
- doneCalled = true ;
203
- doneErr . push ( err ) ;
204
- } ,
204
+ ( ) => ( doneCalled = true ) ,
205
+ ( err : any ) => doneErr . push ( err ) ,
205
206
) ;
206
207
207
208
verify ( fakeRequestor . webRequest ( anything ( ) , anyFunction ( ) ) ) ;
@@ -217,9 +218,8 @@ describe('Watch', () => {
217
218
expect ( receivedObjects ) . to . deep . equal ( [ obj1 . object ] ) ;
218
219
219
220
expect ( doneCalled ) . to . equal ( true ) ;
220
- expect ( doneErr . length ) . to . equal ( 2 ) ;
221
+ expect ( doneErr . length ) . to . equal ( 1 ) ;
221
222
expect ( doneErr [ 0 ] ) . to . deep . equal ( errIn ) ;
222
- expect ( doneErr [ 1 ] ) . to . deep . equal ( errIn ) ;
223
223
} ) ;
224
224
225
225
it ( 'should handle server side close correctly' , async ( ) => {
@@ -258,10 +258,8 @@ describe('Watch', () => {
258
258
receivedTypes . push ( phase ) ;
259
259
receivedObjects . push ( obj ) ;
260
260
} ,
261
- ( err : any ) => {
262
- doneCalled = true ;
263
- doneErr = err ;
264
- } ,
261
+ ( ) => ( doneCalled = true ) ,
262
+ ( err : any ) => ( doneErr = err ) ,
265
263
) ;
266
264
267
265
verify ( fakeRequestor . webRequest ( anything ( ) , anyFunction ( ) ) ) ;
@@ -277,7 +275,7 @@ describe('Watch', () => {
277
275
expect ( receivedObjects ) . to . deep . equal ( [ obj1 . object ] ) ;
278
276
279
277
expect ( doneCalled ) . to . equal ( true ) ;
280
- expect ( doneErr ) . to . be . null ;
278
+ expect ( doneErr ) . to . be . undefined ;
281
279
} ) ;
282
280
283
281
it ( 'should ignore JSON parse errors' , async ( ) => {
@@ -317,6 +315,9 @@ describe('Watch', () => {
317
315
( ) => {
318
316
/* ignore */
319
317
} ,
318
+ ( ) => {
319
+ /* ignore */
320
+ } ,
320
321
) ;
321
322
322
323
verify ( fakeRequestor . webRequest ( anything ( ) , anyFunction ( ) ) ) ;
@@ -332,7 +333,7 @@ describe('Watch', () => {
332
333
const kc = new KubeConfig ( ) ;
333
334
const watch = new Watch ( kc ) ;
334
335
335
- const promise = watch . watch ( '/some/path' , { } , ( ) => { } , ( ) => { } ) ;
336
+ const promise = watch . watch ( '/some/path' , { } , ( ) => { } , ( ) => { } , ( ) => { } ) ;
336
337
expect ( promise ) . to . be . rejected ;
337
338
} ) ;
338
339
} ) ;
0 commit comments