diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index 81aadf26169179..df3a87f73c8d15 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -20,15 +20,11 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +const { mustCall, mustNotCall } = require('../common'); const assert = require('assert'); -const binding = process.binding('http_parser'); -const methods = binding.methods; -const HTTPParser = binding.HTTPParser; - -const REQUEST = HTTPParser.REQUEST; -const RESPONSE = HTTPParser.RESPONSE; +const { methods, HTTPParser } = process.binding('http_parser'); +const { REQUEST, RESPONSE } = HTTPParser; const kOnHeaders = HTTPParser.kOnHeaders | 0; const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; @@ -55,7 +51,7 @@ function newParser(type) { parser[kOnHeadersComplete] = function() { }; - parser[kOnBody] = common.mustNotCall('kOnBody should not be called'); + parser[kOnBody] = mustNotCall('kOnBody should not be called'); parser[kOnMessageComplete] = function() { }; @@ -64,21 +60,6 @@ function newParser(type) { } -function mustCall(f, times) { - let actual = 0; - - process.setMaxListeners(256); - process.on('exit', function() { - assert.strictEqual(actual, times || 1); - }); - - return function() { - actual++; - return f.apply(this, Array.prototype.slice.call(arguments)); - }; -} - - function expectBody(expected) { return mustCall(function(buf, start, len) { const body = String(buf.slice(start, start + len));