@@ -6,18 +6,18 @@ const http = require('node:http')
66const https = require ( 'node:https' )
77const pem = require ( '@metcoder95/https-pem' )
88const fs = require ( 'node:fs' )
9- const { tspl } = require ( '@matteo.collina/tspl ' )
9+ const { once } = require ( 'node:events ' )
1010
1111const skip = process . platform === 'win32'
1212
1313test ( 'http unix get' , { skip } , async ( t ) => {
1414 let client
15- const p = tspl ( t , { plan : 7 } )
15+ t . plan ( 7 )
1616
1717 const server = http . createServer ( { joinDuplicateHeaders : true } , ( req , res ) => {
18- p . equal ( '/' , req . url )
19- p . equal ( 'GET' , req . method )
20- p . equal ( 'localhost' , req . headers . host )
18+ t . assert . strictEqual ( '/' , req . url )
19+ t . assert . strictEqual ( 'GET' , req . method )
20+ t . assert . strictEqual ( 'localhost' , req . headers . host )
2121 res . setHeader ( 'Content-Type' , 'text/plain' )
2222 res . end ( 'hello' )
2323 } )
@@ -42,31 +42,32 @@ test('http unix get', { skip }, async (t) => {
4242 } )
4343
4444 client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
45- p . ifError ( err )
45+ t . assert . ifError ( err )
4646 const { statusCode, headers, body } = data
47- p . equal ( statusCode , 200 )
48- p . equal ( headers [ 'content-type' ] , 'text/plain' )
47+ t . assert . strictEqual ( statusCode , 200 )
48+ t . assert . strictEqual ( headers [ 'content-type' ] , 'text/plain' )
4949 const bufs = [ ]
5050 body . on ( 'data' , ( buf ) => {
5151 bufs . push ( buf )
5252 } )
5353 body . on ( 'end' , ( ) => {
54- p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
54+ t . assert . strictEqual ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
55+ server . close ( )
5556 } )
5657 } )
5758 } )
5859
59- await p . completed
60+ await once ( server , 'close' )
6061} )
6162
6263test ( 'http unix get pool' , { skip } , async ( t ) => {
6364 let client
64- const p = tspl ( t , { plan : 7 } )
65+ t . plan ( 7 )
6566
6667 const server = http . createServer ( { joinDuplicateHeaders : true } , ( req , res ) => {
67- p . equal ( '/' , req . url )
68- p . equal ( 'GET' , req . method )
69- p . equal ( 'localhost' , req . headers . host )
68+ t . assert . strictEqual ( '/' , req . url )
69+ t . assert . strictEqual ( 'GET' , req . method )
70+ t . assert . strictEqual ( 'localhost' , req . headers . host )
7071 res . setHeader ( 'Content-Type' , 'text/plain' )
7172 res . end ( 'hello' )
7273 } )
@@ -91,30 +92,32 @@ test('http unix get pool', { skip }, async (t) => {
9192 } )
9293
9394 client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
94- p . ifError ( err )
95+ t . assert . ifError ( err )
9596 const { statusCode, headers, body } = data
96- p . equal ( statusCode , 200 )
97- p . equal ( headers [ 'content-type' ] , 'text/plain' )
97+ t . assert . strictEqual ( statusCode , 200 )
98+ t . assert . strictEqual ( headers [ 'content-type' ] , 'text/plain' )
9899 const bufs = [ ]
99100 body . on ( 'data' , ( buf ) => {
100101 bufs . push ( buf )
101102 } )
102103 body . on ( 'end' , ( ) => {
103- p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
104+ t . assert . strictEqual ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
105+ server . close ( )
104106 } )
105107 } )
106108 } )
107109
108- await p . completed
110+ await once ( server , 'close' )
109111} )
110112
111113test ( 'https get with tls opts' , { skip } , async ( t ) => {
114+ t . plan ( 6 )
115+
112116 let client
113- const p = tspl ( t , { plan : 6 } )
114117
115118 const server = https . createServer ( { ...pem , joinDuplicateHeaders : true } , ( req , res ) => {
116- p . equal ( '/' , req . url )
117- p . equal ( 'GET' , req . method )
119+ t . assert . strictEqual ( '/' , req . url )
120+ t . assert . strictEqual ( 'GET' , req . method )
118121 res . setHeader ( 'content-type' , 'text/plain' )
119122 res . end ( 'hello' )
120123 } )
@@ -142,18 +145,20 @@ test('https get with tls opts', { skip }, async (t) => {
142145 } )
143146
144147 client . request ( { path : '/' , method : 'GET' } , ( err , data ) => {
145- p . ifError ( err )
148+ t . assert . ifError ( err )
146149 const { statusCode, headers, body } = data
147- p . equal ( statusCode , 200 )
148- p . equal ( headers [ 'content-type' ] , 'text/plain' )
150+ t . assert . strictEqual ( statusCode , 200 )
151+ t . assert . strictEqual ( headers [ 'content-type' ] , 'text/plain' )
149152 const bufs = [ ]
150153 body . on ( 'data' , ( buf ) => {
151154 bufs . push ( buf )
152155 } )
153156 body . on ( 'end' , ( ) => {
154- p . equal ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
157+ t . assert . strictEqual ( 'hello' , Buffer . concat ( bufs ) . toString ( 'utf8' ) )
158+ server . close ( )
155159 } )
156160 } )
157161 } )
158- await p . completed
162+
163+ await once ( server , 'close' )
159164} )
0 commit comments