File tree 1 file changed +44
-0
lines changed
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+
5
+ const dnsPromises = require ( 'dns' ) . promises ;
6
+
7
+ common . crashOnUnhandledRejection ( ) ;
8
+
9
+ // Error when rrtype is invalid.
10
+ {
11
+ const rrtype = 'DUMMY' ;
12
+ common . expectsError (
13
+ ( ) => dnsPromises . resolve ( 'example.org' , rrtype ) ,
14
+ {
15
+ code : 'ERR_INVALID_OPT_VALUE' ,
16
+ type : TypeError ,
17
+ message : `The value "${ rrtype } " is invalid for option "rrtype"`
18
+ }
19
+ ) ;
20
+ }
21
+
22
+ // Error when rrtype is a number.
23
+ {
24
+ const rrtype = 0 ;
25
+ common . expectsError (
26
+ ( ) => dnsPromises . resolve ( 'example.org' , rrtype ) ,
27
+ {
28
+ code : 'ERR_INVALID_ARG_TYPE' ,
29
+ type : TypeError ,
30
+ message : 'The "rrtype" argument must be of type string. ' +
31
+ `Received type ${ typeof rrtype } `
32
+ }
33
+ ) ;
34
+ }
35
+
36
+ // rrtype is undefined, it's same as resolve4
37
+ {
38
+ ( async function ( ) {
39
+ const rrtype = undefined ;
40
+ const result = await dnsPromises . resolve ( 'example.org' , rrtype ) ;
41
+ assert . ok ( result !== undefined ) ;
42
+ assert . ok ( result . length > 0 ) ;
43
+ } ) ( ) ;
44
+ }
You can’t perform that action at this time.
0 commit comments