@@ -2122,7 +2122,7 @@ describe('supports http with nodejs', function () {
21222122 } ) ;
21232123
21242124 describe ( 'DNS' , function ( ) {
2125- it ( 'should support custom DNS lookup function' , async function ( ) {
2125+ it ( 'should support a custom DNS lookup function' , async function ( ) {
21262126 server = await startHTTPServer ( SERVER_HANDLER_STREAM_ECHO ) ;
21272127
21282128 const payload = 'test' ;
@@ -2141,7 +2141,26 @@ describe('supports http with nodejs', function () {
21412141 assert . strictEqual ( data , payload ) ;
21422142 } ) ;
21432143
2144- it ( 'should support custom DNS lookup function (async)' , async function ( ) {
2144+ it ( 'should support a custom DNS lookup function with address entry passing' , async function ( ) {
2145+ server = await startHTTPServer ( SERVER_HANDLER_STREAM_ECHO ) ;
2146+
2147+ const payload = 'test' ;
2148+
2149+ let isCalled = false ;
2150+
2151+ const { data} = await axios . post ( `http://fake-name.axios:4444` , payload , {
2152+ lookup : ( hostname , opt , cb ) => {
2153+ isCalled = true ;
2154+ cb ( null , { address : '127.0.0.1' , family : 4 } ) ;
2155+ }
2156+ } ) ;
2157+
2158+ assert . ok ( isCalled ) ;
2159+
2160+ assert . strictEqual ( data , payload ) ;
2161+ } ) ;
2162+
2163+ it ( 'should support a custom DNS lookup function (async)' , async function ( ) {
21452164 server = await startHTTPServer ( SERVER_HANDLER_STREAM_ECHO ) ;
21462165
21472166 const payload = 'test' ;
@@ -2160,7 +2179,26 @@ describe('supports http with nodejs', function () {
21602179 assert . strictEqual ( data , payload ) ;
21612180 } ) ;
21622181
2163- it ( 'should support custom DNS lookup function that returns only IP address (async)' , async function ( ) {
2182+ it ( 'should support a custom DNS lookup function with address entry (async)' , async function ( ) {
2183+ server = await startHTTPServer ( SERVER_HANDLER_STREAM_ECHO ) ;
2184+
2185+ const payload = 'test' ;
2186+
2187+ let isCalled = false ;
2188+
2189+ const { data} = await axios . post ( `http://fake-name.axios:4444` , payload , {
2190+ lookup : async ( hostname , opt ) => {
2191+ isCalled = true ;
2192+ return { address : '127.0.0.1' , family : 4 } ;
2193+ }
2194+ } ) ;
2195+
2196+ assert . ok ( isCalled ) ;
2197+
2198+ assert . strictEqual ( data , payload ) ;
2199+ } ) ;
2200+
2201+ it ( 'should support a custom DNS lookup function that returns only IP address (async)' , async function ( ) {
21642202 server = await startHTTPServer ( SERVER_HANDLER_STREAM_ECHO ) ;
21652203
21662204 const payload = 'test' ;
0 commit comments