diff options
Diffstat (limited to 'test/parallel/test-http-hex-write.js')
-rw-r--r-- | test/parallel/test-http-hex-write.js | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/test/parallel/test-http-hex-write.js b/test/parallel/test-http-hex-write.js index 5b5729712d..adfe18077a 100644 --- a/test/parallel/test-http-hex-write.js +++ b/test/parallel/test-http-hex-write.js @@ -1,18 +1,10 @@ 'use strict'; -require('../common'); +const common = require('../common'); var assert = require('assert'); var http = require('http'); var expect = 'hex\nutf8\n'; -var data = ''; -var ended = false; - -process.on('exit', function() { - assert(ended); - assert.equal(data, expect); - console.log('ok'); -}); http.createServer(function(q, s) { s.setHeader('content-length', expect.length); @@ -20,14 +12,17 @@ http.createServer(function(q, s) { s.write('utf8\n'); s.end(); this.close(); -}).listen(0, function() { - http.request({ port: this.address().port }).on('response', function(res) { - res.setEncoding('ascii'); - res.on('data', function(c) { - data += c; - }); - res.on('end', function() { - ended = true; - }); - }).end(); -}); +}).listen(0, common.mustCall(function() { + http.request({ port: this.address().port }) + .on('response', common.mustCall(function(res) { + var data = ''; + + res.setEncoding('ascii'); + res.on('data', function(c) { + data += c; + }); + res.on('end', common.mustCall(function() { + assert.strictEqual(data, expect); + })); + })).end(); +})); |