From cbec2843361f86e43d8dc780982b0098526d4d9a Mon Sep 17 00:00:00 2001 From: Masashi Hirano Date: Fri, 27 Jul 2018 08:11:04 +0900 Subject: [PATCH] test: check arg type for dnsPromises.resolve to increase coverage. --- test/parallel/test-dns.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 3a44be92804746..dcef59e43f90a1 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -135,14 +135,31 @@ assert.deepStrictEqual(dns.getServers(), portsExpected); dns.setServers([]); assert.deepStrictEqual(dns.getServers(), []); -common.expectsError(() => { - dns.resolve('example.com', [], common.mustNotCall()); -}, { - code: 'ERR_INVALID_ARG_TYPE', - type: TypeError, - message: 'The "rrtype" argument must be of type string. ' + - 'Received type object' -}); +{ + const errObj = { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "rrtype" argument must be of type string. ' + + 'Received type object' + }; + common.expectsError(() => { + dns.resolve('example.com', [], common.mustNotCall()); + }, errObj); + common.expectsError(() => { + dnsPromises.resolve('example.com', []); + }, errObj); +} +{ + const errObj = { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: 'The "name" argument must be of type string. ' + + 'Received type undefined' + }; + common.expectsError(() => { + dnsPromises.resolve(); + }, errObj); +} // dns.lookup should accept only falsey and string values {