test agent option `family` being passed to `lookup`

This commit is contained in:
Bernhard K. Weisshuhn 2018-06-19 19:08:34 +02:00 committed by Gregor Martynus
parent a33d6b0de1
commit 287bc3bdcf
1 changed files with 16 additions and 0 deletions

View File

@ -1545,6 +1545,22 @@ describe('node-fetch', () => {
expect(called).to.equal(2);
});
});
it("supports supplying a famliy option to the agent", function() {
const url = `${base}redirect/301`;
const families = [];
const family = Symbol('family');
function lookupSpy(hostname, options, callback) {
families.push(options.family)
return lookup(hostname, {}, callback);
}
const agent = http.Agent({ lookup: lookupSpy, family });
return fetch(url, { agent }).then(() => {
expect(families).to.have.length(2);
expect(families[0]).to.equal(family);
expect(families[1]).to.equal(family);
});
});
});
describe('Headers', function () {