File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 2020// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
2222'use strict' ;
23- require ( '../common' ) ;
23+ const common = require ( '../common' ) ;
2424const assert = require ( 'assert' ) ;
2525const http = require ( 'http' ) ;
2626
2727const expected = 'Post Body For Test' ;
28+ const expectedStatusCode = 200 ;
2829
2930const server = http . Server ( function ( req , res ) {
3031 let result = '' ;
@@ -34,12 +35,12 @@ const server = http.Server(function(req, res) {
3435 result += chunk ;
3536 } ) ;
3637
37- req . on ( 'end' , function ( ) {
38+ req . on ( 'end' , common . mustCall ( ( ) => {
3839 assert . strictEqual ( result , expected ) ;
39- res . writeHead ( 200 ) ;
40+ res . writeHead ( expectedStatusCode ) ;
4041 res . end ( 'hello world\n' ) ;
4142 server . close ( ) ;
42- } ) ;
43+ } ) ) ;
4344
4445} ) ;
4546
@@ -49,12 +50,9 @@ server.listen(0, function() {
4950 path : '/' ,
5051 method : 'POST'
5152 } , function ( res ) {
52- console . log ( res . statusCode ) ;
53+ assert . strictEqual ( res . statusCode , expectedStatusCode ) ;
5354 res . resume ( ) ;
54- } ) . on ( 'error' , function ( e ) {
55- console . log ( e . message ) ;
56- process . exit ( 1 ) ;
57- } ) ;
55+ } ) . on ( 'error' , common . mustNotCall ( ) ) ;
5856
5957 const result = req . end ( expected ) ;
6058
You can’t perform that action at this time.
0 commit comments