11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding');
61cb0ef41Sopenharmony_ciconst cares = internalBinding('cares_wrap');
71cb0ef41Sopenharmony_cicares.getaddrinfo = () => internalBinding('uv').UV_ENOMEM;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// This test ensures that dns.lookup issue a DeprecationWarning
101cb0ef41Sopenharmony_ci// when invalid options type is given
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst dnsPromises = require('dns/promises');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cicommon.expectWarning({
151cb0ef41Sopenharmony_ci  'internal/test/binding': [
161cb0ef41Sopenharmony_ci    'These APIs are for internal testing only. Do not use them.',
171cb0ef41Sopenharmony_ci  ],
181cb0ef41Sopenharmony_ci});
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciassert.throws(() => {
211cb0ef41Sopenharmony_ci  dnsPromises.lookup('127.0.0.1', { hints: '-1' });
221cb0ef41Sopenharmony_ci}, {
231cb0ef41Sopenharmony_ci  code: 'ERR_INVALID_ARG_TYPE',
241cb0ef41Sopenharmony_ci  name: 'TypeError'
251cb0ef41Sopenharmony_ci});
261cb0ef41Sopenharmony_ciassert.throws(() => dnsPromises.lookup('127.0.0.1', { hints: -1 }),
271cb0ef41Sopenharmony_ci              { code: 'ERR_INVALID_ARG_VALUE' });
281cb0ef41Sopenharmony_ciassert.throws(() => dnsPromises.lookup('127.0.0.1', { family: '6' }),
291cb0ef41Sopenharmony_ci              { code: 'ERR_INVALID_ARG_VALUE' });
301cb0ef41Sopenharmony_ciassert.throws(() => dnsPromises.lookup('127.0.0.1', { all: 'true' }),
311cb0ef41Sopenharmony_ci              { code: 'ERR_INVALID_ARG_TYPE' });
321cb0ef41Sopenharmony_ciassert.throws(() => dnsPromises.lookup('127.0.0.1', { verbatim: 'true' }),
331cb0ef41Sopenharmony_ci              { code: 'ERR_INVALID_ARG_TYPE' });
341cb0ef41Sopenharmony_ciassert.throws(() => dnsPromises.lookup('127.0.0.1', '6'),
351cb0ef41Sopenharmony_ci              { code: 'ERR_INVALID_ARG_TYPE' });
36