forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve test coverage of dns/promises
PR-URL: nodejs#41133 Refs: https://coverage.nodejs.org/coverage-18ff5832501b66b4/lib/internal/dns/promises.js.html#L116 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Qingyu Deng <[email protected]>
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test/parallel/test-dns-lookup-promises-options-deprecated.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { internalBinding } = require('internal/test/binding'); | ||
const cares = internalBinding('cares_wrap'); | ||
cares.getaddrinfo = () => internalBinding('uv').UV_ENOMEM; | ||
|
||
// This test ensures that dns.lookup issue a DeprecationWarning | ||
// when invalid options type is given | ||
|
||
const dnsPromises = require('dns/promises'); | ||
|
||
common.expectWarning({ | ||
'internal/test/binding': [ | ||
'These APIs are for internal testing only. Do not use them.', | ||
], | ||
'DeprecationWarning': { | ||
DEP0153: 'Type coercion of dns.lookup options is deprecated' | ||
} | ||
}); | ||
|
||
assert.throws(() => { | ||
dnsPromises.lookup('127.0.0.1', { hints: '-1' }); | ||
}, { | ||
code: 'ERR_INVALID_ARG_VALUE', | ||
name: 'TypeError' | ||
}); | ||
dnsPromises.lookup('127.0.0.1', { family: '6' }); | ||
dnsPromises.lookup('127.0.0.1', { all: 'true' }); | ||
dnsPromises.lookup('127.0.0.1', { verbatim: 'true' }); | ||
dnsPromises.lookup('127.0.0.1', '6'); |