@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"
5
5
6
6
import { NodeHttpHandler } from "./node-http-handler" ;
7
7
import * as setConnectionTimeoutModule from "./set-connection-timeout" ;
8
+ import * as setSocketTimeoutModule from "./set-socket-timeout" ;
8
9
import { timing } from "./timing" ;
9
10
10
11
vi . mock ( "http" , async ( ) => {
@@ -56,6 +57,7 @@ describe("NodeHttpHandler", () => {
56
57
const randomMaxSocket = Math . round ( Math . random ( ) * 50 ) + 1 ;
57
58
const randomSocketAcquisitionWarningTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
58
59
const randomConnectionTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
60
+ const randomRequestTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
59
61
60
62
beforeEach ( ( ) => { } ) ;
61
63
@@ -129,6 +131,21 @@ describe("NodeHttpHandler", () => {
129
131
) ;
130
132
} ) ;
131
133
134
+ it . each ( [
135
+ [ "an options hash" , { requestTimeout : randomRequestTimeout } ] ,
136
+ [
137
+ "a provider" ,
138
+ async ( ) => ( {
139
+ requestTimeout : randomRequestTimeout ,
140
+ } ) ,
141
+ ] ,
142
+ ] ) ( "sets requestTimeout correctly when input is %s" , async ( _ , option ) => {
143
+ vi . spyOn ( setSocketTimeoutModule , "setSocketTimeout" ) ;
144
+ const nodeHttpHandler = new NodeHttpHandler ( option ) ;
145
+ await nodeHttpHandler . handle ( { } as any ) ;
146
+ expect ( vi . mocked ( setSocketTimeoutModule . setSocketTimeout ) . mock . calls [ 0 ] [ 2 ] ) . toBe ( randomRequestTimeout ) ;
147
+ } ) ;
148
+
132
149
it . each ( [
133
150
[ "an options hash" , { httpAgent : new http . Agent ( { keepAlive : false , maxSockets : randomMaxSocket } ) } ] ,
134
151
[
0 commit comments