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