Skip to content

Commit e79351c

Browse files
Williams-DanMylesBorins
authored andcommitted
test: improve test-https-agent.js
On line 40: replace '==' with '===' On line 52: replace 'assert.equal' with 'assert.strictEqual' Added some comments. Changed 'var' to 'const' where possible. Replaced console.log(res.statusCode); with and assertion. Rather than logging the https request status on every loop it will now assert the https status is correct on every loop. Changed the error listener to throw the error rather than log it. PR-URL: #8517 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9ffb2f3 commit e79351c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/parallel/test-https-agent.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

55
if (!common.hasCrypto) {
66
common.skip('missing crypto');
77
return;
88
}
9-
var https = require('https');
9+
const https = require('https');
1010

11-
var fs = require('fs');
11+
const fs = require('fs');
1212

13-
var options = {
13+
const options = {
1414
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
1515
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
1616
};
1717

1818

19-
var server = https.Server(options, function(req, res) {
19+
const server = https.Server(options, function(req, res) {
2020
res.writeHead(200);
2121
res.end('hello world\n');
2222
});
2323

2424

2525
var responses = 0;
26-
var N = 4;
27-
var M = 4;
26+
const N = 4;
27+
const M = 4;
28+
2829

2930
server.listen(0, function() {
3031
for (var i = 0; i < N; i++) {
@@ -36,11 +37,10 @@ server.listen(0, function() {
3637
rejectUnauthorized: false
3738
}, function(res) {
3839
res.resume();
39-
console.log(res.statusCode);
40-
if (++responses == N * M) server.close();
40+
assert.strictEqual(res.statusCode, 200);
41+
if (++responses === N * M) server.close();
4142
}).on('error', function(e) {
42-
console.log(e.message);
43-
process.exit(1);
43+
throw e;
4444
});
4545
}
4646
}, i);
@@ -49,5 +49,5 @@ server.listen(0, function() {
4949

5050

5151
process.on('exit', function() {
52-
assert.equal(N * M, responses);
52+
assert.strictEqual(N * M, responses);
5353
});

0 commit comments

Comments
 (0)