| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c31fa24 commit 5e1fd28
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,21 +1,21 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - var assert = require('assert'); | ||
| 4 | - var http = require('http'); | ||
| 5 | - var util = require('util'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const http = require('http'); | ||
| 5 | + const util = require('util'); | ||
| 6 | 6 | ||
| 7 | - var Duplex = require('stream').Duplex; | ||
| 7 | + const Duplex = require('stream').Duplex; | ||
| 8 | 8 | ||
| 9 | 9 | function FakeAgent() { | |
| 10 | 10 | http.Agent.call(this); | |
| 11 | 11 | } | |
| 12 | 12 | util.inherits(FakeAgent, http.Agent); | |
| 13 | 13 | ||
| 14 | - FakeAgent.prototype.createConnection = function createConnection() { | ||
| 15 | - var s = new Duplex(); | ||
| 14 | + FakeAgent.prototype.createConnection = function() { | ||
| 15 | + const s = new Duplex(); | ||
| 16 | 16 | var once = false; | |
| 17 | 17 | ||
| 18 | - s._read = function _read() { | ||
| 18 | + s._read = function() { | ||
| 19 | 19 | if (once) | |
| 20 | 20 | return this.push(null); | |
| 21 | 21 | once = true; | |
@@ -27,11 +27,11 @@ FakeAgent.prototype.createConnection = function createConnection() { | |||
| 27 | 27 | }; | |
| 28 | 28 | ||
| 29 | 29 | // Blackhole | |
| 30 | - s._write = function _write(data, enc, cb) { | ||
| 30 | + s._write = function(data, enc, cb) { | ||
| 31 | 31 | cb(); | |
| 32 | 32 | }; | |
| 33 | 33 | ||
| 34 | - s.destroy = s.destroySoon = function destroy() { | ||
| 34 | + s.destroy = s.destroySoon = function() { | ||
| 35 | 35 | this.writable = false; | |
| 36 | 36 | }; | |
| 37 | 37 | ||
@@ -40,17 +40,15 @@ FakeAgent.prototype.createConnection = function createConnection() { | |||
| 40 | 40 | ||
| 41 | 41 | var received = ''; | |
| 42 | 42 | ||
| 43 | - var req = http.request({ | ||
| 43 | + const req = http.request({ | ||
| 44 | 44 | agent: new FakeAgent() | |
| 45 | - }, common.mustCall(function(res) { | ||
| 46 | - res.on('data', function(chunk) { | ||
| 45 | + }, common.mustCall(function requestCallback(res) { | ||
| 46 | + res.on('data', function dataCallback(chunk) { | ||
| 47 | 47 | received += chunk; | |
| 48 | 48 | }); | |
| 49 | 49 | ||
| 50 | - res.on('end', common.mustCall(function() {})); | ||
| 50 | + res.on('end', common.mustCall(function endCallback() { | ||
| 51 | + assert.strictEqual(received, 'hello world'); | ||
| 52 | + })); | ||
| 51 | 53 | })); | |
| 52 | 54 | req.end(); | |
| 53 | - | ||
| 54 | - process.on('exit', function() { | ||
| 55 | - assert.equal(received, 'hello world'); | ||
| 56 | - }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments