1'use strict';
2
3require('../common');
4const common = require('../common');
5const dns = require('dns');
6const dnsPromises = dns.promises;
7const { addresses } = require('../common/internet');
8const assert = require('assert');
9
10assert.rejects(
11  dnsPromises.lookup(addresses.NOT_FOUND, {
12    hints: 0,
13    family: 0,
14    all: false,
15  }),
16  {
17    code: 'ENOTFOUND',
18    message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
19  },
20);
21
22assert.rejects(
23  dnsPromises.lookup(addresses.NOT_FOUND, {
24    hints: 0,
25    family: 0,
26    all: true,
27  }),
28  {
29    code: 'ENOTFOUND',
30    message: `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
31  },
32);
33
34dns.lookup(addresses.NOT_FOUND, {
35  hints: 0,
36  family: 0,
37  all: true,
38}, common.mustCall((error) => {
39  assert.strictEqual(error.code, 'ENOTFOUND');
40  assert.strictEqual(
41    error.message,
42    `getaddrinfo ENOTFOUND ${addresses.NOT_FOUND}`,
43  );
44  assert.strictEqual(error.syscall, 'getaddrinfo');
45  assert.strictEqual(error.hostname, addresses.NOT_FOUND);
46}));
47
48assert.throws(
49  () => dnsPromises.lookup(addresses.NOT_FOUND, {
50    family: 'ipv4',
51    all: 'all',
52  }),
53  { code: 'ERR_INVALID_ARG_VALUE' },
54);
55