@@ -5,7 +5,7 @@ const assert = require('assert');
55const dns = require ( 'dns' ) ;
66
77var existing = dns . getServers ( ) ;
8- assert ( existing . length ) ;
8+ assert ( existing . length > 0 ) ;
99
1010function noop ( ) { }
1111
@@ -15,7 +15,8 @@ var goog = [
1515] ;
1616assert . doesNotThrow ( function ( ) { dns . setServers ( goog ) ; } ) ;
1717assert . 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 $ / ) ;
1920assert . deepEqual ( dns . getServers ( ) , goog ) ;
2021
2122var goog6 = [
@@ -50,25 +51,28 @@ assert.throws(function() {
5051} , 'Unexpected error' ) ;
5152
5253// 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+
5357assert . throws ( function ( ) {
5458 dns . lookup ( { } , noop ) ;
55- } , 'invalid arguments: hostname must be a string or falsey' ) ;
59+ } , errorReg ) ;
5660
5761assert . throws ( function ( ) {
5862 dns . lookup ( [ ] , noop ) ;
59- } , 'invalid arguments: hostname must be a string or falsey' ) ;
63+ } , errorReg ) ;
6064
6165assert . throws ( function ( ) {
6266 dns . lookup ( true , noop ) ;
63- } , 'invalid arguments: hostname must be a string or falsey' ) ;
67+ } , errorReg ) ;
6468
6569assert . throws ( function ( ) {
6670 dns . lookup ( 1 , noop ) ;
67- } , 'invalid arguments: hostname must be a string or falsey' ) ;
71+ } , errorReg ) ;
6872
6973assert . throws ( function ( ) {
7074 dns . lookup ( noop , noop ) ;
71- } , 'invalid arguments: hostname must be a string or falsey' ) ;
75+ } , errorReg ) ;
7276
7377assert . doesNotThrow ( function ( ) {
7478 dns . lookup ( '' , noop ) ;
@@ -102,15 +106,15 @@ assert.doesNotThrow(function() {
102106assert . throws ( function ( ) {
103107 dns . lookup ( 'www.google.com' , { hints : ( dns . V4MAPPED | dns . ADDRCONFIG ) + 1 } ,
104108 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 $ / ) ;
106110
107111assert . throws ( function ( ) {
108112 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 $ / ) ;
110114
111115assert . throws ( function ( ) {
112116 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 $ / ) ;
114118
115119assert . doesNotThrow ( function ( ) {
116120 dns . lookup ( 'www.google.com' , 6 , noop ) ;
@@ -148,15 +152,15 @@ assert.doesNotThrow(function() {
148152
149153assert . throws ( function ( ) {
150154 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 $ / ) ;
152156
153157assert . throws ( function ( ) {
154158 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 $ / ) ;
156160
157161assert . throws ( function ( ) {
158162 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 " $ / ) ;
160164
161165assert . doesNotThrow ( function ( ) {
162166 dns . lookupService ( '0.0.0.0' , 0 , noop ) ;
0 commit comments