Skip to content

Commit 287bc3b

Browse files
bkwgr2m
authored andcommitted
test agent option family being passed to lookup
1 parent a33d6b0 commit 287bc3b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,22 @@ describe('node-fetch', () => {
15451545
expect(called).to.equal(2);
15461546
});
15471547
});
1548+
1549+
it("supports supplying a famliy option to the agent", function() {
1550+
const url = `${base}redirect/301`;
1551+
const families = [];
1552+
const family = Symbol('family');
1553+
function lookupSpy(hostname, options, callback) {
1554+
families.push(options.family)
1555+
return lookup(hostname, {}, callback);
1556+
}
1557+
const agent = http.Agent({ lookup: lookupSpy, family });
1558+
return fetch(url, { agent }).then(() => {
1559+
expect(families).to.have.length(2);
1560+
expect(families[0]).to.equal(family);
1561+
expect(families[1]).to.equal(family);
1562+
});
1563+
});
15481564
});
15491565

15501566
describe('Headers', function () {

0 commit comments

Comments
 (0)