@@ -219,18 +219,22 @@ describe(NodeHttp2Handler.name, () => {
219
219
} ) ;
220
220
221
221
describe ( "destroy" , ( ) => {
222
- it ( "destroys sessions and clears connectionPool" , async ( ) => {
222
+ it ( "destroys session and clears connectionPool" , async ( ) => {
223
223
await nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , { } ) ;
224
224
225
225
// @ts -ignore: access private property
226
- const session : ClientHttp2Session = nodeH2Handler . connectionPool . get ( ` ${ protocol } // ${ hostname } : ${ port } ` ) ;
226
+ const session : ClientHttp2Session = nodeH2Handler . connections [ 0 ] ;
227
227
228
228
// @ts -ignore: access private property
229
229
expect ( nodeH2Handler . connectionPool . size ) . toBe ( 1 ) ;
230
+ // @ts -ignore: access private property
231
+ expect ( nodeH2Handler . connections . length ) . toBe ( 1 ) ;
230
232
expect ( session . destroyed ) . toBe ( false ) ;
231
233
nodeH2Handler . destroy ( ) ;
232
234
// @ts -ignore: access private property
233
235
expect ( nodeH2Handler . connectionPool . size ) . toBe ( 0 ) ;
236
+ // @ts -ignore: access private property
237
+ expect ( nodeH2Handler . connections . length ) . toBe ( 0 ) ;
234
238
expect ( session . destroyed ) . toBe ( true ) ;
235
239
} ) ;
236
240
} ) ;
@@ -429,5 +433,22 @@ describe(NodeHttp2Handler.name, () => {
429
433
mockH2Server2 . close ( ) ;
430
434
} ) ;
431
435
} ) ;
436
+
437
+ describe ( "destroy" , ( ) => {
438
+ it ( "destroys session and clears connections" , async ( ) => {
439
+ await nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , { } ) ;
440
+
441
+ // @ts -ignore: access private property
442
+ const session : ClientHttp2Session = nodeH2Handler . connections [ 0 ] ;
443
+
444
+ // @ts -ignore: access private property
445
+ expect ( nodeH2Handler . connections . length ) . toBe ( 1 ) ;
446
+ expect ( session . destroyed ) . toBe ( false ) ;
447
+ nodeH2Handler . destroy ( ) ;
448
+ // @ts -ignore: access private property
449
+ expect ( nodeH2Handler . connections . length ) . toBe ( 0 ) ;
450
+ expect ( session . destroyed ) . toBe ( true ) ;
451
+ } ) ;
452
+ } ) ;
432
453
} ) ;
433
454
} ) ;
0 commit comments