@@ -47,12 +47,7 @@ describe(NodeHttp2Handler.name, () => {
47
47
} ) ;
48
48
49
49
afterEach ( ( ) => {
50
- // @ts -ignore: access private property
51
- const sessionPool = nodeH2Handler . sessionPool ;
52
- for ( const [ , session ] of sessionPool ) {
53
- session . destroy ( ) ;
54
- }
55
- sessionPool . clear ( ) ;
50
+ nodeH2Handler . destroy ( ) ;
56
51
} ) ;
57
52
58
53
it ( "has metadata" , ( ) => {
@@ -219,30 +214,30 @@ describe(NodeHttp2Handler.name, () => {
219
214
} ) ;
220
215
221
216
describe ( "destroy" , ( ) => {
222
- it ( "destroys session and clears sessionPool " , async ( ) => {
217
+ it ( "destroys session and clears sessionCache " , async ( ) => {
223
218
await nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , { } ) ;
224
219
225
220
// @ts -ignore: access private property
226
- const session : ClientHttp2Session = nodeH2Handler . sessions [ 0 ] ;
221
+ const session : ClientHttp2Session = nodeH2Handler . sessionList [ 0 ] ;
227
222
228
223
// @ts -ignore: access private property
229
- expect ( nodeH2Handler . sessionPool . size ) . toBe ( 1 ) ;
224
+ expect ( nodeH2Handler . sessionCache . size ) . toBe ( 1 ) ;
230
225
// @ts -ignore: access private property
231
- expect ( nodeH2Handler . sessions . length ) . toBe ( 1 ) ;
226
+ expect ( nodeH2Handler . sessionList . length ) . toBe ( 1 ) ;
232
227
expect ( session . destroyed ) . toBe ( false ) ;
233
228
nodeH2Handler . destroy ( ) ;
234
229
// @ts -ignore: access private property
235
- expect ( nodeH2Handler . sessionPool . size ) . toBe ( 0 ) ;
230
+ expect ( nodeH2Handler . sessionCache . size ) . toBe ( 0 ) ;
236
231
// @ts -ignore: access private property
237
- expect ( nodeH2Handler . sessions . length ) . toBe ( 0 ) ;
232
+ expect ( nodeH2Handler . sessionList . length ) . toBe ( 0 ) ;
238
233
expect ( session . destroyed ) . toBe ( true ) ;
239
234
} ) ;
240
235
} ) ;
241
236
242
237
describe ( "abortSignal" , ( ) => {
243
238
it ( "will not create session if request already aborted" , async ( ) => {
244
239
// @ts -ignore: access private property
245
- expect ( nodeH2Handler . sessionPool . size ) . toBe ( 0 ) ;
240
+ expect ( nodeH2Handler . sessionCache . size ) . toBe ( 0 ) ;
246
241
await expect (
247
242
nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , {
248
243
abortSignal : {
@@ -252,15 +247,15 @@ describe(NodeHttp2Handler.name, () => {
252
247
} )
253
248
) . rejects . toHaveProperty ( "name" , "AbortError" ) ;
254
249
// @ts -ignore: access private property
255
- expect ( nodeH2Handler . sessionPool . size ) . toBe ( 0 ) ;
250
+ expect ( nodeH2Handler . sessionCache . size ) . toBe ( 0 ) ;
256
251
} ) ;
257
252
258
253
it ( "will not create request on session if request already aborted" , async ( ) => {
259
254
// Create a session by sending a request.
260
255
await nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , { } ) ;
261
256
262
257
// @ts -ignore: access private property
263
- const session : ClientHttp2Session = nodeH2Handler . sessions [ 0 ] ;
258
+ const session : ClientHttp2Session = nodeH2Handler . sessionList [ 0 ] ;
264
259
const requestSpy = jest . spyOn ( session , "request" ) ;
265
260
266
261
await expect (
@@ -347,15 +342,15 @@ describe(NodeHttp2Handler.name, () => {
347
342
348
343
const authority = `${ protocol } //${ hostname } :${ port } ` ;
349
344
// @ts -ignore: access private property
350
- const session : ClientHttp2Session = nodeH2Handler . sessions [ 0 ] ;
345
+ const session : ClientHttp2Session = nodeH2Handler . sessionList [ 0 ] ;
351
346
expect ( session . closed ) . toBe ( false ) ;
352
347
// @ts -ignore: access private property
353
- expect ( nodeH2Handler . sessionPool . get ( authority ) ) . toBeDefined ( ) ;
348
+ expect ( nodeH2Handler . sessionCache . get ( authority ) ) . toBeDefined ( ) ;
354
349
setTimeout ( ( ) => {
355
350
expect ( session . closed ) . toBe ( true ) ;
356
351
expect ( session . destroyed ) . toBe ( false ) ;
357
352
// @ts -ignore: access private property
358
- expect ( nodeH2Handler . sessionPool . get ( authority ) ) . not . toBeDefined ( ) ;
353
+ expect ( nodeH2Handler . sessionCache . get ( authority ) ) . not . toBeDefined ( ) ;
359
354
done ( ) ;
360
355
} , sessionTimeout + 100 ) ;
361
356
} ) ;
@@ -365,7 +360,7 @@ describe(NodeHttp2Handler.name, () => {
365
360
await nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , { } ) ;
366
361
367
362
// @ts -ignore: access private property
368
- const session : ClientHttp2Session = nodeH2Handler . sessions [ 0 ] ;
363
+ const session : ClientHttp2Session = nodeH2Handler . sessionList [ 0 ] ;
369
364
expect ( session . closed ) . toBe ( false ) ;
370
365
setTimeout ( ( ) => {
371
366
expect ( session . closed ) . toBe ( true ) ;
@@ -435,18 +430,18 @@ describe(NodeHttp2Handler.name, () => {
435
430
} ) ;
436
431
437
432
describe ( "destroy" , ( ) => {
438
- it ( "destroys session and clears connections " , async ( ) => {
433
+ it ( "destroys session and empties sessionList " , async ( ) => {
439
434
await nodeH2Handler . handle ( new HttpRequest ( getMockReqOptions ( ) ) , { } ) ;
440
435
441
436
// @ts -ignore: access private property
442
- const session : ClientHttp2Session = nodeH2Handler . sessions [ 0 ] ;
437
+ const session : ClientHttp2Session = nodeH2Handler . sessionList [ 0 ] ;
443
438
444
439
// @ts -ignore: access private property
445
- expect ( nodeH2Handler . sessions . length ) . toBe ( 1 ) ;
440
+ expect ( nodeH2Handler . sessionList . length ) . toBe ( 1 ) ;
446
441
expect ( session . destroyed ) . toBe ( false ) ;
447
442
nodeH2Handler . destroy ( ) ;
448
443
// @ts -ignore: access private property
449
- expect ( nodeH2Handler . sessions . length ) . toBe ( 0 ) ;
444
+ expect ( nodeH2Handler . sessionList . length ) . toBe ( 0 ) ;
450
445
expect ( session . destroyed ) . toBe ( true ) ;
451
446
} ) ;
452
447
} ) ;
0 commit comments