1'use strict';
2
3const { mustCall } = require('../common');
4const { strictEqual } = require('assert');
5const { Agent, get } = require('http');
6
7// Test that the listener that forwards the `'timeout'` event from the socket to
8// the `ClientRequest` instance is added to the socket when the `timeout` option
9// of the `Agent` is set.
10
11const request = get({
12  agent: new Agent({ timeout: 50 }),
13  lookup: () => {}
14});
15
16request.on('socket', mustCall((socket) => {
17  strictEqual(socket.timeout, 50);
18
19  const listeners = socket.listeners('timeout');
20
21  strictEqual(listeners.length, 2);
22  strictEqual(listeners[1], request.timeoutCb);
23}));
24