Skip to content

Commit 2fb1381

Browse files
sam-githubMylesBorins
authored andcommitted
doc: document and test that methods return this
Also, add tests to ensure they will always return this, and to confirm they return this when these doc changes are back-ported to earlier release lines. PR-URL: nodejs#13553 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 34fc7a0 commit 2fb1381

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

‎test/parallel/test-net-end-close.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const s = new net.Socket({
1414
},
1515
writable: false
1616
});
17-
s.resume();
17+
assert.strictEqual(s,s.resume());
1818

1919
constevents=[];
2020

‎test/parallel/test-net-server-close.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let server = net.createServer(function(c){
2323
sockets.push(c);
2424

2525
if(sockets.length===2){
26-
server.close();
26+
assert.strictEqual(server.close(),server);
2727
sockets.forEach(function(c){c.destroy();});
2828
}
2929
});
@@ -32,7 +32,7 @@ server.on('close', function(){
3232
events.push('server');
3333
});
3434

35-
server.listen(0,function(){
35+
assert.strictEqual(server,server.listen(0,function(){
3636
net.createConnection(this.address().port);
3737
net.createConnection(this.address().port);
38-
});
38+
}));

‎test/parallel/test-net-socket-local-address.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ function connect(){
3434

3535
conns++;
3636
client.once('close',connect);
37-
client.connect(server.address().port,common.localhostIPv4,()=>{
38-
clientLocalPorts.push(client.localPort);
39-
});
37+
assert.strictEqual(
38+
client,
39+
client.connect(server.address().port,common.localhostIPv4,()=>{
40+
clientLocalPorts.push(client.localPort);
41+
})
42+
);
4043
}

‎test/parallel/test-net-stream.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const server = net.createServer(function(socket){
3939
}).listen(0,function(){
4040
constconn=net.connect(this.address().port);
4141
conn.on('data',function(buf){
42-
conn.pause();
42+
assert.strictEqual(conn,conn.pause());
4343
setTimeout(function(){
4444
conn.destroy();
4545
},20);

0 commit comments

Comments
(0)