Skip to content

Commit cf3c635

Browse files
davidmarkclementsFishrock123
davidmarkclements
authored andcommitted
test: refactor test-https-truncate
Changes assert.equal to assert.strictEqual to ensure specificity. Changes var declarations to const/let where appropriate. PR-URL: #10074 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]>
1 parent 14c0388 commit cf3c635

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/parallel/test-https-truncate.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
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 key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
14-
var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
13+
const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem');
14+
const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem');
1515

1616
// number of bytes discovered empirically to trigger the bug
17-
var data = Buffer.allocUnsafe(1024 * 32 + 1);
17+
const data = Buffer.allocUnsafe(1024 * 32 + 1);
1818

1919
httpsTest();
2020

2121
function httpsTest() {
22-
var sopt = { key: key, cert: cert };
22+
const sopt = { key: key, cert: cert };
2323

24-
var server = https.createServer(sopt, function(req, res) {
24+
const server = https.createServer(sopt, function(req, res) {
2525
res.setHeader('content-length', data.length);
2626
res.end(data);
2727
server.close();
2828
});
2929

3030
server.listen(0, function() {
31-
var opts = { port: this.address().port, rejectUnauthorized: false };
31+
const opts = { port: this.address().port, rejectUnauthorized: false };
3232
https.get(opts).on('response', function(res) {
3333
test(res);
3434
});
@@ -38,14 +38,14 @@ function httpsTest() {
3838

3939
function test(res) {
4040
res.on('end', function() {
41-
assert.equal(res._readableState.length, 0);
42-
assert.equal(bytes, data.length);
41+
assert.strictEqual(res._readableState.length, 0);
42+
assert.strictEqual(bytes, data.length);
4343
console.log('ok');
4444
});
4545

4646
// Pause and then resume on each chunk, to ensure that there will be
4747
// a lone byte hanging out at the very end.
48-
var bytes = 0;
48+
let bytes = 0;
4949
res.on('data', function(chunk) {
5050
bytes += chunk.length;
5151
this.pause();

0 commit comments

Comments
 (0)