summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-timeout-option-with-agent.js
blob: 833c21c8929b7286e70224100d3a603bda9ccf18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'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, 2);
  strictEqual(listeners[1], request.timeoutCb);
}));