@@ -5,7 +5,7 @@ const assert = require('assert');
5
5
const dns = require ( 'dns' ) ;
6
6
7
7
var existing = dns . getServers ( ) ;
8
- assert ( existing . length ) ;
8
+ assert ( existing . length > 0 ) ;
9
9
10
10
function noop ( ) { }
11
11
@@ -15,7 +15,8 @@ var goog = [
15
15
] ;
16
16
assert . doesNotThrow ( function ( ) { dns . setServers ( goog ) ; } ) ;
17
17
assert . deepEqual ( dns . getServers ( ) , goog ) ;
18
- assert . throws ( function ( ) { dns . setServers ( [ 'foobar' ] ) ; } ) ;
18
+ assert . throws ( function ( ) { dns . setServers ( [ 'foobar' ] ) ; } ,
19
+ / ^ E r r o r : I P a d d r e s s i s n o t p r o p e r l y f o r m a t t e d : f o o b a r $ / ) ;
19
20
assert . deepEqual ( dns . getServers ( ) , goog ) ;
20
21
21
22
var goog6 = [
@@ -50,25 +51,28 @@ assert.throws(function() {
50
51
} , 'Unexpected error' ) ;
51
52
52
53
// dns.lookup should accept falsey and string values
54
+ const errorReg =
55
+ / ^ T y p e E r r o r : i n v a l i d a r g u m e n t s : h o s t n a m e m u s t b e a s t r i n g o r f a l s e y $ / ;
56
+
53
57
assert . throws ( function ( ) {
54
58
dns . lookup ( { } , noop ) ;
55
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
59
+ } , errorReg ) ;
56
60
57
61
assert . throws ( function ( ) {
58
62
dns . lookup ( [ ] , noop ) ;
59
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
63
+ } , errorReg ) ;
60
64
61
65
assert . throws ( function ( ) {
62
66
dns . lookup ( true , noop ) ;
63
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
67
+ } , errorReg ) ;
64
68
65
69
assert . throws ( function ( ) {
66
70
dns . lookup ( 1 , noop ) ;
67
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
71
+ } , errorReg ) ;
68
72
69
73
assert . throws ( function ( ) {
70
74
dns . lookup ( noop , noop ) ;
71
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
75
+ } , errorReg ) ;
72
76
73
77
assert . doesNotThrow ( function ( ) {
74
78
dns . lookup ( '' , noop ) ;
@@ -102,15 +106,15 @@ assert.doesNotThrow(function() {
102
106
assert . throws ( function ( ) {
103
107
dns . lookup ( 'www.google.com' , { hints : ( dns . V4MAPPED | dns . ADDRCONFIG ) + 1 } ,
104
108
noop ) ;
105
- } ) ;
109
+ } , / ^ T y p e E r r o r : i n v a l i d a r g u m e n t : h i n t s m u s t u s e v a l i d f l a g s $ / ) ;
106
110
107
111
assert . throws ( function ( ) {
108
112
dns . lookup ( 'www.google.com' ) ;
109
- } , ' invalid arguments: callback must be passed' ) ;
113
+ } , / ^ T y p e E r r o r : i n v a l i d a r g u m e n t s : c a l l b a c k m u s t b e p a s s e d $ / ) ;
110
114
111
115
assert . throws ( function ( ) {
112
116
dns . lookup ( 'www.google.com' , 4 ) ;
113
- } , ' invalid arguments: callback must be passed' ) ;
117
+ } , / ^ T y p e E r r o r : i n v a l i d a r g u m e n t s : c a l l b a c k m u s t b e p a s s e d $ / ) ;
114
118
115
119
assert . doesNotThrow ( function ( ) {
116
120
dns . lookup ( 'www.google.com' , 6 , noop ) ;
@@ -148,15 +152,15 @@ assert.doesNotThrow(function() {
148
152
149
153
assert . throws ( function ( ) {
150
154
dns . lookupService ( '0.0.0.0' ) ;
151
- } , / i n v a l i d a r g u m e n t s / ) ;
155
+ } , / ^ E r r o r : i n v a l i d a r g u m e n t s $ / ) ;
152
156
153
157
assert . throws ( function ( ) {
154
158
dns . lookupService ( 'fasdfdsaf' , 0 , noop ) ;
155
- } , / h o s t n e e d s t o b e a v a l i d I P a d d r e s s / ) ;
159
+ } , / ^ T y p e E r r o r : h o s t n e e d s t o b e a v a l i d I P a d d r e s s $ / ) ;
156
160
157
161
assert . throws ( function ( ) {
158
162
dns . lookupService ( '0.0.0.0' , '0' , noop ) ;
159
- } , / p o r t a r g u m e n t m u s t b e a n u m b e r , g o t " 0 " / ) ;
163
+ } , / ^ T y p e E r r o r : p o r t a r g u m e n t m u s t b e a n u m b e r , g o t " 0 " $ / ) ;
160
164
161
165
assert . doesNotThrow ( function ( ) {
162
166
dns . lookupService ( '0.0.0.0' , 0 , noop ) ;
0 commit comments