GeezerVison is showing github.com — test: improve test coverage of dns/promises · nodejs/node@f067876
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +32Lines changed: 32 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Flags: --expose-internals |
| 2 | +'use strict'; |
| 3 | +const common = require('../common'); |
| 4 | +const assert = require('assert'); |
| 5 | +const { internalBinding } = require('internal/test/binding'); |
| 6 | +const cares = internalBinding('cares_wrap'); |
| 7 | +cares.getaddrinfo = () => internalBinding('uv').UV_ENOMEM; |
| 8 | + |
| 9 | +// This test ensures that dns.lookup issue a DeprecationWarning |
| 10 | +// when invalid options type is given |
| 11 | + |
| 12 | +const dnsPromises = require('dns/promises'); |
| 13 | + |
| 14 | +common.expectWarning({ |
| 15 | + 'internal/test/binding': [ |
| 16 | + 'These APIs are for internal testing only. Do not use them.', |
| 17 | + ], |
| 18 | + 'DeprecationWarning': { |
| 19 | + DEP0153: 'Type coercion of dns.lookup options is deprecated' |
| 20 | + } |
| 21 | +}); |
| 22 | + |
| 23 | +assert.throws(() => { |
| 24 | + dnsPromises.lookup('127.0.0.1', { hints: '-1' }); |
| 25 | +}, { |
| 26 | + code: 'ERR_INVALID_ARG_VALUE', |
| 27 | + name: 'TypeError' |
| 28 | +}); |
| 29 | +dnsPromises.lookup('127.0.0.1', { family: '6' }); |
| 30 | +dnsPromises.lookup('127.0.0.1', { all: 'true' }); |
| 31 | +dnsPromises.lookup('127.0.0.1', { verbatim: 'true' }); |
| 32 | +dnsPromises.lookup('127.0.0.1', '6'); |