@@ -149,7 +149,7 @@ describe('Watch', () => {
149
149
150
150
expect ( doneCalled ) . to . equal ( 0 ) ;
151
151
152
- // TODO check after noe -fetch fix
152
+ // TODO check after node -fetch fix
153
153
// https://github.com/node-fetch/node-fetch/issues/1231
154
154
// https://github.com/node-fetch/node-fetch/issues/1721
155
155
@@ -229,6 +229,66 @@ describe('Watch', () => {
229
229
s . done ( ) ;
230
230
} ) ;
231
231
232
+ // https://github.com/node-fetch/node-fetch/issues/1231
233
+ // https://github.com/node-fetch/node-fetch/issues/1721
234
+ it . skip ( 'should handle server side close correctly' , async ( ) => {
235
+ const kc = new KubeConfig ( ) ;
236
+ Object . assign ( kc , fakeConfig ) ;
237
+ const watch = new Watch ( kc ) ;
238
+
239
+ const obj1 = {
240
+ type : 'ADDED' ,
241
+ object : {
242
+ foo : 'bar' ,
243
+ } ,
244
+ } ;
245
+
246
+ const stream = new PassThrough ( ) ;
247
+
248
+ const [ scope ] = systemUnderTest ( ) ;
249
+
250
+ const path = '/some/path/to/object?watch=true' ;
251
+
252
+ const s = scope . get ( path ) . reply ( 200 , ( ) => {
253
+ stream . push ( JSON . stringify ( obj1 ) + '\n' ) ;
254
+ return stream ;
255
+ } ) ;
256
+
257
+ const receivedTypes : string [ ] = [ ] ;
258
+ const receivedObjects : string [ ] = [ ] ;
259
+ const doneErr : any [ ] = [ ] ;
260
+
261
+ let doneResolve : any ;
262
+ const donePromise = new Promise ( ( resolve ) => {
263
+ doneResolve = resolve ;
264
+ } ) ;
265
+
266
+ await watch . watch (
267
+ path ,
268
+ { } ,
269
+ ( phase : string , obj : string ) => {
270
+ receivedTypes . push ( phase ) ;
271
+ receivedObjects . push ( obj ) ;
272
+ } ,
273
+ ( err : any ) => {
274
+ doneErr . push ( err ) ;
275
+ doneResolve ( ) ;
276
+ } ,
277
+ ) ;
278
+
279
+ stream . emit ( 'close' ) ;
280
+
281
+ await donePromise ;
282
+
283
+ expect ( receivedTypes ) . to . deep . equal ( [ obj1 . type ] ) ;
284
+ expect ( receivedObjects ) . to . deep . equal ( [ obj1 . object ] ) ;
285
+
286
+ expect ( doneErr . length ) . to . equal ( 1 ) ;
287
+ expect ( doneErr [ 0 ] ) . to . be . null ;
288
+
289
+ s . done ( ) ;
290
+ } ) ;
291
+
232
292
it ( 'should ignore JSON parse errors' , async ( ) => {
233
293
const kc = new KubeConfig ( ) ;
234
294
Object . assign ( kc , fakeConfig ) ;
0 commit comments