From 3cae010ea0c0cfbd0dc88ec2de09a513ef5f5ae0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 23 Mar 2019 09:42:30 -0700 Subject: [PATCH] test: refactor test-https-connect-localport Use arrow functions for callbacks. Replace uses of `this` with explicit variables. Add a trailing comma in a multiline object literal declaration. PR-URL: https://github.com/nodejs/node/pull/26881 Fixes: https://github.com/https://github.com/nodejs/node/issues/26862 Reviewed-By: Luigi Pinca Reviewed-By: Yongsheng Zhang Reviewed-By: Gireesh Punathil Reviewed-By: Daijiro Wachi --- test/sequential/test-https-connect-localport.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/sequential/test-https-connect-localport.js b/test/sequential/test-https-connect-localport.js index 67b56c7d7d6b80..e703fb2287d369 100644 --- a/test/sequential/test-https-connect-localport.js +++ b/test/sequential/test-https-connect-localport.js @@ -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);