Skip to content

Commit e451022

Browse files
Trottevanlucas
authored andcommitted
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: #9344 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 0c236d1 commit e451022

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
'use strict';
22
constcommon=require('../common');
3-
varassert=require('assert');
4-
varhttp=require('http');
5-
varutil=require('util');
3+
constassert=require('assert');
4+
consthttp=require('http');
5+
constutil=require('util');
66

7-
varDuplex=require('stream').Duplex;
7+
constDuplex=require('stream').Duplex;
88

99
functionFakeAgent(){
1010
http.Agent.call(this);
1111
}
1212
util.inherits(FakeAgent,http.Agent);
1313

14-
FakeAgent.prototype.createConnection=functioncreateConnection(){
15-
vars=newDuplex();
14+
FakeAgent.prototype.createConnection=function(){
15+
consts=newDuplex();
1616
varonce=false;
1717

18-
s._read=function_read(){
18+
s._read=function(){
1919
if(once)
2020
returnthis.push(null);
2121
once=true;
@@ -27,11 +27,11 @@ FakeAgent.prototype.createConnection = function createConnection(){
2727
};
2828

2929
// Blackhole
30-
s._write=function_write(data,enc,cb){
30+
s._write=function(data,enc,cb){
3131
cb();
3232
};
3333

34-
s.destroy=s.destroySoon=functiondestroy(){
34+
s.destroy=s.destroySoon=function(){
3535
this.writable=false;
3636
};
3737

@@ -40,17 +40,15 @@ FakeAgent.prototype.createConnection = function createConnection(){
4040

4141
varreceived='';
4242

43-
varreq=http.request({
43+
constreq=http.request({
4444
agent: newFakeAgent()
45-
},common.mustCall(function(res){
46-
res.on('data',function(chunk){
45+
},common.mustCall(functionrequestCallback(res){
46+
res.on('data',functiondataCallback(chunk){
4747
received+=chunk;
4848
});
4949

50-
res.on('end',common.mustCall(function(){}));
50+
res.on('end',common.mustCall(functionendCallback(){
51+
assert.strictEqual(received,'hello world');
52+
}));
5153
}));
5254
req.end();
53-
54-
process.on('exit',function(){
55-
assert.equal(received,'hello world');
56-
});

0 commit comments

Comments
(0)