@@ -4,6 +4,7 @@ import https from "https";
4
4
import { afterEach , beforeEach , describe , expect , test as it , vi } from "vitest" ;
5
5
6
6
import { NodeHttpHandler } from "./node-http-handler" ;
7
+ import { timing } from "./timing" ;
7
8
8
9
vi . mock ( "http" , async ( ) => {
9
10
const actual = ( await vi . importActual ( "http" ) ) as any ;
@@ -52,6 +53,7 @@ import { request as hsRequest } from "https";
52
53
describe ( "NodeHttpHandler" , ( ) => {
53
54
describe ( "constructor and #handle" , ( ) => {
54
55
const randomMaxSocket = Math . round ( Math . random ( ) * 50 ) + 1 ;
56
+ const randomSocketAcquisitionWarningTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
55
57
56
58
beforeEach ( ( ) => { } ) ;
57
59
@@ -93,6 +95,21 @@ describe("NodeHttpHandler", () => {
93
95
expect ( vi . mocked ( hRequest as any ) . mock . calls [ 0 ] [ 0 ] ?. agent . maxSockets ) . toEqual ( 50 ) ;
94
96
} ) ;
95
97
98
+ it . each ( [
99
+ [ "an options hash" , { socketAcquisitionWarningTimeout : randomSocketAcquisitionWarningTimeout } ] ,
100
+ [
101
+ "a provider" ,
102
+ async ( ) => ( {
103
+ socketAcquisitionWarningTimeout : randomSocketAcquisitionWarningTimeout ,
104
+ } ) ,
105
+ ] ,
106
+ ] ) ( "sets socketAcquisitionWarningTimeout correctly when input is %s" , async ( _ , option ) => {
107
+ vi . spyOn ( timing , "setTimeout" ) ;
108
+ const nodeHttpHandler = new NodeHttpHandler ( option ) ;
109
+ await nodeHttpHandler . handle ( { } as any ) ;
110
+ expect ( vi . mocked ( timing . setTimeout ) . mock . calls [ 0 ] [ 1 ] ) . toBe ( randomSocketAcquisitionWarningTimeout ) ;
111
+ } ) ;
112
+
96
113
it . each ( [
97
114
[ "an options hash" , { httpAgent : new http . Agent ( { keepAlive : false , maxSockets : randomMaxSocket } ) } ] ,
98
115
[
0 commit comments