File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,6 +353,7 @@ describe("openHttpConnectTunnel", () => {
353353
354354 it ( "caps oversized CONNECT timeouts before arming the watchdog" , async ( ) => {
355355 vi . useFakeTimers ( ) ;
356+ const setTimeoutSpy = vi . spyOn ( globalThis , "setTimeout" ) ;
356357 const proxySocket = new FakeSocket ( ) ;
357358 setNextNetSocket ( proxySocket ) ;
358359 const { openHttpConnectTunnel } = await import ( "./http-connect-tunnel.js" ) ;
@@ -363,14 +364,16 @@ describe("openHttpConnectTunnel", () => {
363364 targetPort : 443 ,
364365 timeoutMs : Number . MAX_SAFE_INTEGER ,
365366 } ) ;
367+ const rejected = expect ( tunnel ) . rejects . toThrow (
368+ `Proxy CONNECT failed via http://proxy.example:8080: Proxy CONNECT timed out after ${ MAX_TIMER_TIMEOUT_MS } ms` ,
369+ ) ;
370+ expect ( setTimeoutSpy ) . toHaveBeenCalledWith ( expect . any ( Function ) , MAX_TIMER_TIMEOUT_MS ) ;
366371
367372 await vi . advanceTimersByTimeAsync ( 1 ) ;
368373 expect ( proxySocket . destroyed ) . toBe ( false ) ;
369374
370- await vi . advanceTimersByTimeAsync ( MAX_TIMER_TIMEOUT_MS - 1 ) ;
371- await expect ( tunnel ) . rejects . toThrow (
372- `Proxy CONNECT failed via http://proxy.example:8080: Proxy CONNECT timed out after ${ MAX_TIMER_TIMEOUT_MS } ms` ,
373- ) ;
375+ await vi . advanceTimersToNextTimerAsync ( ) ;
376+ await rejected ;
374377 expect ( proxySocket . destroyed ) . toBe ( true ) ;
375378 } ) ;
376379} ) ;
You can’t perform that action at this time.
0 commit comments