node/test/parallel/test-http-request-dont-override-options.js
Ruben Bridgewater 50dd555910
doc,lib,test: capitalize comment sentences
This activates the eslint capitalize comment rule for comments
above 50 characters.

PR-URL: https://github.com/nodejs/node/pull/24996
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-17 17:14:35 +01:00

41 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const server = http.createServer(common.mustCall(function(req, res) {
res.writeHead(200);
res.end('ok');
}));
server.listen(0, function() {
const agent = new http.Agent();
agent.defaultPort = this.address().port;
// Options marked as explicitly undefined for readability
// in this test, they should STAY undefined as options should not
// be mutable / modified
const options = {
host: undefined,
hostname: common.localhostIPv4,
port: undefined,
defaultPort: undefined,
path: undefined,
method: undefined,
agent: agent
};
http.request(options, function(res) {
res.resume();
server.close();
assert.strictEqual(options.host, undefined);
assert.strictEqual(options.hostname, common.localhostIPv4);
assert.strictEqual(options.port, undefined);
assert.strictEqual(options.defaultPort, undefined);
assert.strictEqual(options.path, undefined);
assert.strictEqual(options.method, undefined);
}).end();
});