0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-http-agent-getname.js
Brendan Ashworth 2965442308 http: fix agent.getName() and add tests
This commit fixes agent.getName(), which returned an extra colon
according to the docs, and adds tests (it was previously not unit
tested).

PR-URL: https://github.com/nodejs/io.js/pull/1617
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-04 11:56:17 -07:00

33 lines
504 B
JavaScript

'use strict';
var assert = require('assert');
var http = require('http');
var common = require('../common');
var agent = new http.Agent();
// default to localhost
assert.equal(
agent.getName({
port: 80,
localAddress: '192.168.1.1'
}),
'localhost:80:192.168.1.1'
);
// empty
assert.equal(
agent.getName({}),
'localhost::'
);
// pass all arguments
assert.equal(
agent.getName({
host: '0.0.0.0',
port: 80,
localAddress: '192.168.1.1'
}),
'0.0.0.0:80:192.168.1.1'
);