@@ -152,10 +152,20 @@ describe("ensureAddress", () => {
152152 it ( "should throw and error if no address" , ( ) => {
153153 expect ( ( ) => ensureAddress ( mockServer , "http" ) ) . toThrow ( "Server has no address" )
154154 } )
155- it ( "should return the address if it exists " , async ( ) => {
156- mockServer . address = ( ) => "http://localhost:8080/ "
155+ it ( "should return the address if it's a string " , async ( ) => {
156+ mockServer . address = ( ) => "/path/to/unix.sock "
157157 const address = ensureAddress ( mockServer , "http" )
158- expect ( address . toString ( ) ) . toBe ( `http://localhost:8080/` )
158+ expect ( address . toString ( ) ) . toBe ( `/path/to/unix.sock` )
159+ } )
160+ it ( "should construct URL with an IPv4 address" , async ( ) => {
161+ mockServer . address = ( ) => ( { address : "1.2.3.4" , port : 5678 , family : "IPv4" } )
162+ const address = ensureAddress ( mockServer , "http" )
163+ expect ( address . toString ( ) ) . toBe ( `http://1.2.3.4:5678/` )
164+ } )
165+ it ( "should construct URL with an IPv6 address" , async ( ) => {
166+ mockServer . address = ( ) => ( { address : "a:b:c:d::1234" , port : 5678 , family : "IPv6" } )
167+ const address = ensureAddress ( mockServer , "http" )
168+ expect ( address . toString ( ) ) . toBe ( `http://[a:b:c:d::1234]:5678/` )
159169 } )
160170} )
161171
0 commit comments