• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-internals
2'use strict';
3const common = require('../common');
4const assert = require('assert');
5const { internalBinding } = require('internal/test/binding');
6const cares = internalBinding('cares_wrap');
7cares.getaddrinfo = () => internalBinding('uv').UV_ENOMEM;
8
9// This test ensures that dns.lookup issue a DeprecationWarning
10// when invalid options type is given
11
12const dnsPromises = require('dns/promises');
13
14common.expectWarning({
15  'internal/test/binding': [
16    'These APIs are for internal testing only. Do not use them.',
17  ],
18});
19
20assert.throws(() => {
21  dnsPromises.lookup('127.0.0.1', { hints: '-1' });
22}, {
23  code: 'ERR_INVALID_ARG_TYPE',
24  name: 'TypeError'
25});
26assert.throws(() => dnsPromises.lookup('127.0.0.1', { hints: -1 }),
27              { code: 'ERR_INVALID_ARG_VALUE' });
28assert.throws(() => dnsPromises.lookup('127.0.0.1', { family: '6' }),
29              { code: 'ERR_INVALID_ARG_VALUE' });
30assert.throws(() => dnsPromises.lookup('127.0.0.1', { all: 'true' }),
31              { code: 'ERR_INVALID_ARG_TYPE' });
32assert.throws(() => dnsPromises.lookup('127.0.0.1', { verbatim: 'true' }),
33              { code: 'ERR_INVALID_ARG_TYPE' });
34assert.throws(() => dnsPromises.lookup('127.0.0.1', '6'),
35              { code: 'ERR_INVALID_ARG_TYPE' });
36