Skip to content

Commit ae016c8

Browse files
Masashi Hiranotargos
Masashi Hirano
authored andcommitted
test: add tests for dnsPromises.lookup
Added tests for dnsPromises.lookup to increase coverage and test `onlookup()` and `onlookupall()` methods. PR-URL: #21559 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 7794d4e commit ae016c8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/parallel/test-dns-lookup.js

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const common = require('../common');
3+
const { addresses } = require('../common/internet');
34
const assert = require('assert');
45
const cares = process.binding('cares_wrap');
56
const dns = require('dns');
@@ -92,6 +93,30 @@ common.expectsError(() => {
9293
all: false
9394
});
9495
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });
96+
97+
assert.rejects(
98+
dnsPromises.lookup(addresses.INVALID_HOST, {
99+
hints: 0,
100+
family: 0,
101+
all: false
102+
}),
103+
{
104+
code: 'ENOTFOUND',
105+
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
106+
}
107+
);
108+
109+
assert.rejects(
110+
dnsPromises.lookup(addresses.INVALID_HOST, {
111+
hints: 0,
112+
family: 0,
113+
all: true
114+
}),
115+
{
116+
code: 'ENOTFOUND',
117+
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
118+
}
119+
);
95120
})();
96121

97122
dns.lookup(false, {

0 commit comments

Comments
 (0)