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 <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
pull/26823/head
Rich Trott 2019-03-23 09:42:30 -07:00
parent f5969f08a0
commit 4a40ea6894
1 changed files with 8 additions and 6 deletions

View File

@ -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);