@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, test as it, vi } from "vitest"
55
66import { NodeHttpHandler } from "./node-http-handler" ;
77import * as setConnectionTimeoutModule from "./set-connection-timeout" ;
8+ import * as setSocketTimeoutModule from "./set-socket-timeout" ;
89import { timing } from "./timing" ;
910
1011vi . mock ( "http" , async ( ) => {
@@ -56,6 +57,7 @@ describe("NodeHttpHandler", () => {
5657 const randomMaxSocket = Math . round ( Math . random ( ) * 50 ) + 1 ;
5758 const randomSocketAcquisitionWarningTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
5859 const randomConnectionTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
60+ const randomRequestTimeout = Math . round ( Math . random ( ) * 10000 ) + 1 ;
5961
6062 beforeEach ( ( ) => { } ) ;
6163
@@ -129,6 +131,21 @@ describe("NodeHttpHandler", () => {
129131 ) ;
130132 } ) ;
131133
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+
132149 it . each ( [
133150 [ "an options hash" , { httpAgent : new http . Agent ( { keepAlive : false , maxSockets : randomMaxSocket } ) } ] ,
134151 [
0 commit comments