summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-readable.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-10-28 11:21:50 -0700
committerRich Trott <rtrott@gmail.com>2016-11-01 14:19:30 -0700
commit7d18a4d9cf73ebcd0e22efe350789dabbb70f90f (patch)
tree791295d062db4b58177f6d4a3652a7db2dd74e5c /test/parallel/test-http-client-readable.js
parentab194123b72e71d0f7121b39089fcde150e803f4 (diff)
downloadandroid-node-v8-7d18a4d9cf73ebcd0e22efe350789dabbb70f90f.tar.gz
android-node-v8-7d18a4d9cf73ebcd0e22efe350789dabbb70f90f.tar.bz2
android-node-v8-7d18a4d9cf73ebcd0e22efe350789dabbb70f90f.zip
test: refactor test-http-client-readable
* var -> const * remove function names where V8 inference is as good or better * add function names where there is no V8 inference * assert.equal -> strictEqual * move assertion from exit handler to response end handler PR-URL: https://github.com/nodejs/node/pull/9344 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test/parallel/test-http-client-readable.js')
-rw-r--r--test/parallel/test-http-client-readable.js32
1 files changed, 15 insertions, 17 deletions
diff --git a/test/parallel/test-http-client-readable.js b/test/parallel/test-http-client-readable.js
index 3c50dc74f1..e49181cedf 100644
--- a/test/parallel/test-http-client-readable.js
+++ b/test/parallel/test-http-client-readable.js
@@ -1,21 +1,21 @@
'use strict';
const common = require('../common');
-var assert = require('assert');
-var http = require('http');
-var util = require('util');
+const assert = require('assert');
+const http = require('http');
+const util = require('util');
-var Duplex = require('stream').Duplex;
+const Duplex = require('stream').Duplex;
function FakeAgent() {
http.Agent.call(this);
}
util.inherits(FakeAgent, http.Agent);
-FakeAgent.prototype.createConnection = function createConnection() {
- var s = new Duplex();
+FakeAgent.prototype.createConnection = function() {
+ const s = new Duplex();
var once = false;
- s._read = function _read() {
+ s._read = function() {
if (once)
return this.push(null);
once = true;
@@ -27,11 +27,11 @@ FakeAgent.prototype.createConnection = function createConnection() {
};
// Blackhole
- s._write = function _write(data, enc, cb) {
+ s._write = function(data, enc, cb) {
cb();
};
- s.destroy = s.destroySoon = function destroy() {
+ s.destroy = s.destroySoon = function() {
this.writable = false;
};
@@ -40,17 +40,15 @@ FakeAgent.prototype.createConnection = function createConnection() {
var received = '';
-var req = http.request({
+const req = http.request({
agent: new FakeAgent()
-}, common.mustCall(function(res) {
- res.on('data', function(chunk) {
+}, common.mustCall(function requestCallback(res) {
+ res.on('data', function dataCallback(chunk) {
received += chunk;
});
- res.on('end', common.mustCall(function() {}));
+ res.on('end', common.mustCall(function endCallback() {
+ assert.strictEqual(received, 'hello world');
+ }));
}));
req.end();
-
-process.on('exit', function() {
- assert.equal(received, 'hello world');
-});