summaryrefslogtreecommitdiff
path: root/test/parallel/test-c-ares.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-06-11 14:56:33 -0400
committercjihrig <cjihrig@gmail.com>2018-06-20 13:35:27 -0400
commit7486c4d71060e2ae3e754cf01e8fb02696eacd13 (patch)
tree8b48c47271d474800f1222f729e93f477f3fd395 /test/parallel/test-c-ares.js
parentfea3595c2f92beb0d31feb93da1c972cc30e6fec (diff)
downloadandroid-node-v8-7486c4d71060e2ae3e754cf01e8fb02696eacd13.tar.gz
android-node-v8-7486c4d71060e2ae3e754cf01e8fb02696eacd13.tar.bz2
android-node-v8-7486c4d71060e2ae3e754cf01e8fb02696eacd13.zip
dns: add promisified dns module
PR-URL: https://github.com/nodejs/node/pull/21264 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test/parallel/test-c-ares.js')
-rw-r--r--test/parallel/test-c-ares.js36
1 files changed, 31 insertions, 5 deletions
diff --git a/test/parallel/test-c-ares.js b/test/parallel/test-c-ares.js
index 8ba221ca99..59ae40b2b8 100644
--- a/test/parallel/test-c-ares.js
+++ b/test/parallel/test-c-ares.js
@@ -23,8 +23,26 @@
const common = require('../common');
const assert = require('assert');
+common.crashOnUnhandledRejection();
+
const dns = require('dns');
+const dnsPromises = dns.promises;
+
+(async function() {
+ let res;
+
+ res = await dnsPromises.lookup(null);
+ assert.strictEqual(res.address, null);
+ assert.strictEqual(res.family, 4);
+
+ res = await dnsPromises.lookup('127.0.0.1');
+ assert.strictEqual(res.address, '127.0.0.1');
+ assert.strictEqual(res.family, 4);
+ res = await dnsPromises.lookup('::1');
+ assert.strictEqual(res.address, '::1');
+ assert.strictEqual(res.family, 6);
+})();
// Try resolution without callback
@@ -52,14 +70,18 @@ dns.lookup('::1', common.mustCall((error, result, addressType) => {
// Try calling resolve with an unsupported type that's an object key
'toString'
].forEach((val) => {
+ const err = {
+ code: 'ERR_INVALID_OPT_VALUE',
+ type: TypeError,
+ message: `The value "${val}" is invalid for option "rrtype"`
+ };
+
common.expectsError(
() => dns.resolve('www.google.com', val),
- {
- code: 'ERR_INVALID_OPT_VALUE',
- type: TypeError,
- message: `The value "${val}" is invalid for option "rrtype"`
- }
+ err
);
+
+ common.expectsError(() => dnsPromises.resolve('www.google.com', val), err);
});
// Windows doesn't usually have an entry for localhost 127.0.0.1 in
@@ -70,4 +92,8 @@ if (!common.isWindows) {
assert.ifError(error);
assert.ok(Array.isArray(domains));
}));
+
+ (async function() {
+ assert.ok(Array.isArray(await dnsPromises.reverse('127.0.0.1')));
+ })();
}