mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 12:03:30 +00:00

Refactor test-http-client-set-timeout and test-http-client-timeout-option-with-agent. PR-URL: https://github.com/nodejs/node/pull/25473 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
24 lines
555 B
JavaScript
24 lines
555 B
JavaScript
'use strict';
|
|
|
|
// Test that the request `timeout` option has precedence over the agent
|
|
// `timeout` option.
|
|
|
|
const { mustCall } = require('../common');
|
|
const { Agent, get } = require('http');
|
|
const { strictEqual } = require('assert');
|
|
|
|
const request = get({
|
|
agent: new Agent({ timeout: 50 }),
|
|
lookup: () => {},
|
|
timeout: 100
|
|
});
|
|
|
|
request.on('socket', mustCall((socket) => {
|
|
strictEqual(socket.timeout, 100);
|
|
|
|
const listeners = socket.listeners('timeout');
|
|
|
|
strictEqual(listeners.length, 1);
|
|
strictEqual(listeners[0], request.timeoutCb);
|
|
}));
|