Skip to content

Commit

Permalink
test: refactor test-https-connect-localport
Browse files Browse the repository at this point in the history
Use arrow functions for callbacks. Replace uses of `this` with explicit
variables. Add a trailing comma in a multiline object literal
declaration.

PR-URL: nodejs#26881
Fixes: nodejs#26862
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
  • Loading branch information
Trott committed Mar 24, 2019
1 parent f5969f0 commit 4a40ea6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/sequential/test-https-connect-localport.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ const https = require('https');
const assert = require('assert');

{
https.createServer({
const server = https.createServer({
cert: fixtures.readKey('agent1-cert.pem'),
key: fixtures.readKey('agent1-key.pem'),
}, common.mustCall(function(req, res) {
this.close();
}, common.mustCall((req, res) => {
server.close();
res.end();
})).listen(0, 'localhost', common.mustCall(function() {
const port = this.address().port;
}));

server.listen(0, 'localhost', common.mustCall(() => {
const port = server.address().port;
const req = https.get({
host: 'localhost',
pathname: '/',
port,
family: 4,
localPort: common.PORT,
rejectUnauthorized: false
rejectUnauthorized: false,
}, common.mustCall(() => {
assert.strictEqual(req.socket.localPort, common.PORT);
assert.strictEqual(req.socket.remotePort, port);
Expand Down

0 comments on commit 4a40ea6

Please sign in to comment.