Skip to content

Commit f386c0a

Browse files
kaktstargos
authored andcommitted
test: add test for dns.promises.resolve .
PR-URL: #21691 Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 577d24b commit f386c0a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
5+
const dnsPromises = require('dns').promises;
6+
7+
common.crashOnUnhandledRejection();
8+
9+
// Error when rrtype is invalid.
10+
{
11+
const rrtype = 'DUMMY';
12+
common.expectsError(
13+
() => dnsPromises.resolve('example.org', rrtype),
14+
{
15+
code: 'ERR_INVALID_OPT_VALUE',
16+
type: TypeError,
17+
message: `The value "${rrtype}" is invalid for option "rrtype"`
18+
}
19+
);
20+
}
21+
22+
// Error when rrtype is a number.
23+
{
24+
const rrtype = 0;
25+
common.expectsError(
26+
() => dnsPromises.resolve('example.org', rrtype),
27+
{
28+
code: 'ERR_INVALID_ARG_TYPE',
29+
type: TypeError,
30+
message: 'The "rrtype" argument must be of type string. ' +
31+
`Received type ${typeof rrtype}`
32+
}
33+
);
34+
}
35+
36+
// rrtype is undefined, it's same as resolve4
37+
{
38+
(async function() {
39+
const rrtype = undefined;
40+
const result = await dnsPromises.resolve('example.org', rrtype);
41+
assert.ok(result !== undefined);
42+
assert.ok(result.length > 0);
43+
})();
44+
}

0 commit comments

Comments
 (0)