From 1975060a3eb852513bb0db23dfed215b402e1e81 Mon Sep 17 00:00:00 2001 From: Louis Cherel Date: Thu, 29 Feb 2024 13:38:34 +0100 Subject: [PATCH] actually call dns.lookup() in tests to avoid cross-environment conflicts --- test/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/index.js b/test/index.js index c171c41..0dac304 100755 --- a/test/index.js +++ b/test/index.js @@ -7,6 +7,7 @@ const Fs = require('fs'); const Events = require('events'); const Stream = require('stream'); const Zlib = require('zlib'); +const Dns = require('dns'); const Boom = require('@hapi/boom'); const Code = require('@hapi/code'); @@ -1200,19 +1201,17 @@ describe('options.lookup', () => { it('uses the lookup function to resolve the server ip address', async (flags) => { - const server = await internals.server('ok'); - const promise = Wreck.request('get', `http://localhost:${server.address().port}/`, { - lookup: (_hostname, options, callback) => { + let dnsLookupCalled = false; - if (options.all) { - callback(null, [{ address: '127.0.0.1', family: 4 }]); - return; - } + const server = await internals.server('ok'); + await Wreck.request('get', `http://localhost:${server.address().port}/`, { + lookup: (hostname, options, callback) => { - callback(null, '127.0.0.1', 4); + dnsLookupCalled = true; + return Dns.lookup(hostname, options, callback); } }); - await expect(promise).to.not.reject(); + expect(dnsLookupCalled).to.equal(true); flags.onCleanup = () => server.close(); });