@@ -17,16 +17,30 @@ import {
1717
1818describe ( "NodeHttpHandler" , ( ) => {
1919 describe ( "constructor" , ( ) => {
20+ it ( "sets keepAlive=true by default" , ( ) => {
21+ const nodeHttpHandler = new NodeHttpHandler ( ) ;
22+ expect ( ( nodeHttpHandler as any ) . httpAgent . keepAlive ) . toEqual ( true ) ;
23+ } ) ;
24+
25+ it ( "sets maxSockets=50 by default" , ( ) => {
26+ const nodeHttpHandler = new NodeHttpHandler ( ) ;
27+ expect ( ( nodeHttpHandler as any ) . httpAgent . maxSockets ) . toEqual ( 50 ) ;
28+ } ) ;
29+
2030 it ( "can set httpAgent and httpsAgent" , ( ) => {
31+ let keepAlive = false ;
2132 let maxSockets = Math . round ( Math . random ( ) * 50 ) + 1 ;
2233 let nodeHttpHandler = new NodeHttpHandler ( {
23- httpAgent : new http . Agent ( { maxSockets } ) ,
34+ httpAgent : new http . Agent ( { keepAlive , maxSockets } ) ,
2435 } ) ;
36+ expect ( ( nodeHttpHandler as any ) . httpAgent . keepAlive ) . toEqual ( keepAlive ) ;
2537 expect ( ( nodeHttpHandler as any ) . httpAgent . maxSockets ) . toEqual ( maxSockets ) ;
38+ keepAlive = true ;
2639 maxSockets = Math . round ( Math . random ( ) * 50 ) + 1 ;
2740 nodeHttpHandler = new NodeHttpHandler ( {
28- httpsAgent : new https . Agent ( { maxSockets } ) ,
41+ httpsAgent : new https . Agent ( { keepAlive , maxSockets } ) ,
2942 } ) ;
43+ expect ( ( nodeHttpHandler as any ) . httpsAgent . keepAlive ) . toEqual ( keepAlive ) ;
3044 expect ( ( nodeHttpHandler as any ) . httpsAgent . maxSockets ) . toEqual ( maxSockets ) ;
3145 } ) ;
3246 } ) ;
0 commit comments