Skip to content

Commit db9c556

Browse files
committed
test: use shorthand properties
PR-URL: #18105 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent eb68a06 commit db9c556

40 files changed

+55
-86
lines changed

test/fixtures/tls-connect.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ exports.connect = function connect(options, callback) {
4444

4545
const server = {};
4646
const client = {};
47-
const pair = {
48-
server: server,
49-
client: client,
50-
};
47+
const pair = { server, client };
5148

5249
tls.createServer(options.server, function(conn) {
5350
server.conn = conn;

test/internet/test-tls-reuse-host-from-socket.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const tls = require('tls');
3030
const net = require('net');
3131

3232
const socket = net.connect(443, 'www.example.org', common.mustCall(() => {
33-
const secureSocket = tls.connect({ socket: socket }, common.mustCall(() => {
33+
const secureSocket = tls.connect({ socket }, common.mustCall(() => {
3434
secureSocket.destroy();
3535
console.log('ok');
3636
}));

test/parallel/test-child-process-env.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ Object.setPrototypeOf(env, {
3939
let child;
4040
if (common.isWindows) {
4141
child = spawn('cmd.exe', ['/c', 'set'],
42-
Object.assign({}, process.env, { env: env }));
42+
Object.assign({}, process.env, { env }));
4343
} else {
4444
child = spawn('/usr/bin/env', [],
45-
Object.assign({}, process.env, { env: env }));
45+
Object.assign({}, process.env, { env }));
4646
}
4747

4848

test/parallel/test-cluster-dgram-1.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function worker() {
102102

103103
// Every 10 messages, notify the master.
104104
if (received === PACKETS_PER_WORKER) {
105-
process.send({ received: received });
105+
process.send({ received });
106106
socket.close();
107107
}
108108
}, PACKETS_PER_WORKER));

test/parallel/test-cluster-worker-no-exit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if (cluster.isMaster) {
6060

6161
worker = cluster.fork()
6262
.on('online', function() {
63-
this.send({ port: port });
63+
this.send({ port });
6464
});
6565
});
6666
process.on('exit', function() {

test/parallel/test-fs-realpath-buffer-encoding.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ for (encoding in expected) {
2121
const expected_value = expected[encoding];
2222
let result;
2323

24-
result = fs.realpathSync(string_dir, { encoding: encoding });
24+
result = fs.realpathSync(string_dir, { encoding });
2525
assert.strictEqual(result, expected_value);
2626

2727
result = fs.realpathSync(string_dir, encoding);
2828
assert.strictEqual(result, expected_value);
2929

30-
result = fs.realpathSync(buffer_dir, { encoding: encoding });
30+
result = fs.realpathSync(buffer_dir, { encoding });
3131
assert.strictEqual(result, expected_value);
3232

3333
result = fs.realpathSync(buffer_dir, encoding);
@@ -53,7 +53,7 @@ for (encoding in expected) {
5353

5454
fs.realpath(
5555
string_dir,
56-
{ encoding: encoding },
56+
{ encoding },
5757
common.mustCall((err, res) => {
5858
assert.ifError(err);
5959
assert.strictEqual(res, expected_value);
@@ -65,7 +65,7 @@ for (encoding in expected) {
6565
}));
6666
fs.realpath(
6767
buffer_dir,
68-
{ encoding: encoding },
68+
{ encoding },
6969
common.mustCall((err, res) => {
7070
assert.ifError(err);
7171
assert.strictEqual(res, expected_value);

test/parallel/test-fs-write-file-sync.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ common.refreshTmpDir();
5151
// Test writeFileSync
5252
const file1 = path.join(common.tmpDir, 'testWriteFileSync.txt');
5353

54-
fs.writeFileSync(file1, '123', { mode: mode });
54+
fs.writeFileSync(file1, '123', { mode });
5555

5656
content = fs.readFileSync(file1, { encoding: 'utf8' });
5757
assert.strictEqual(content, '123');
@@ -61,7 +61,7 @@ assert.strictEqual(fs.statSync(file1).mode & 0o777, mode);
6161
// Test appendFileSync
6262
const file2 = path.join(common.tmpDir, 'testAppendFileSync.txt');
6363

64-
fs.appendFileSync(file2, 'abc', { mode: mode });
64+
fs.appendFileSync(file2, 'abc', { mode });
6565

6666
content = fs.readFileSync(file2, { encoding: 'utf8' });
6767
assert.strictEqual(content, 'abc');

test/parallel/test-http-client-read-in-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Agent extends http.Agent {
3434
const agent = new Agent();
3535

3636
http.request({
37-
agent: agent
37+
agent
3838
}).once('error', function() {
3939
console.log('ignore');
4040
});

test/parallel/test-http-pipeline-flood.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function child() {
6666
const net = require('net');
6767

6868
const port = +process.argv[3];
69-
const conn = net.connect({ port: port });
69+
const conn = net.connect({ port });
7070

7171
let req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`;
7272

test/parallel/test-http2-create-client-connect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const URL = url.URL;
2222
[`http://localhost:${port}`],
2323
[new URL(`http://localhost:${port}`)],
2424
[url.parse(`http://localhost:${port}`)],
25-
[{ port: port }, { protocol: 'http:' }],
26-
[{ port: port, hostname: '127.0.0.1' }, { protocol: 'http:' }]
25+
[{ port }, { protocol: 'http:' }],
26+
[{ port, hostname: '127.0.0.1' }, { protocol: 'http:' }]
2727
];
2828

2929
const serverClose = new Countdown(items.length + 1,

test/parallel/test-https-agent-create-connection.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ function createServer() {
5151
port: port,
5252
host: host,
5353
rejectUnauthorized: false,
54-
_agentKey: agent.getName({
55-
port: port,
56-
host: host,
57-
}),
54+
_agentKey: agent.getName({ port, host })
5855
};
5956

6057
const socket = agent.createConnection(options);
@@ -70,10 +67,7 @@ function createServer() {
7067
const host = 'localhost';
7168
const options = {
7269
rejectUnauthorized: false,
73-
_agentKey: agent.getName({
74-
port: port,
75-
host: host,
76-
}),
70+
_agentKey: agent.getName({ port, host })
7771
};
7872
const socket = agent.createConnection(port, options);
7973
checkRequest(socket, server);
@@ -88,10 +82,7 @@ function createServer() {
8882
const host = 'localhost';
8983
const options = {
9084
rejectUnauthorized: false,
91-
_agentKey: agent.getName({
92-
port: port,
93-
host: host,
94-
}),
85+
_agentKey: agent.getName({ port, host })
9586
};
9687
const socket = agent.createConnection(port, host, options);
9788
checkRequest(socket, server);

test/parallel/test-https-strict.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ function listening() {
112112

113113
function makeReq(path, port, error, host, ca) {
114114
pending++;
115-
const options = {
116-
port: port,
117-
path: path,
118-
ca: ca
119-
};
115+
const options = { port, path, ca };
120116

121117
if (!ca) {
122118
options.agent = agent0;
@@ -134,7 +130,7 @@ function makeReq(path, port, error, host, ca) {
134130
}
135131

136132
if (host) {
137-
options.headers = { host: host };
133+
options.headers = { host };
138134
}
139135
const req = https.get(options);
140136
const server = port === server1.address().port ? server1 :

test/parallel/test-https-truncate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const data = Buffer.alloc(1024 * 32 + 1);
3838
httpsTest();
3939

4040
function httpsTest() {
41-
const sopt = { key: key, cert: cert };
41+
const sopt = { key, cert };
4242

4343
const server = https.createServer(sopt, function(req, res) {
4444
res.setHeader('content-length', data.length);

test/parallel/test-net-connect-options-port.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const net = require('net');
6060
{
6161
// connect({hint}, cb) and connect({hint})
6262
const hints = (dns.ADDRCONFIG | dns.V4MAPPED) + 42;
63-
const hintOptBlocks = doConnect([{ hints: hints }],
63+
const hintOptBlocks = doConnect([{ hints }],
6464
() => common.mustNotCall());
6565
for (const block of hintOptBlocks) {
6666
common.expectsError(block, {

test/parallel/test-net-server-listen-handle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ if (!common.isWindows) { // Windows doesn't support {fd: <n>}
144144
// Test invalid fd
145145
const fd = fs.openSync(__filename, 'r');
146146
net.createServer()
147-
.listen({ fd: fd }, common.mustNotCall())
147+
.listen({ fd }, common.mustNotCall())
148148
.on('error', common.mustCall(function(err) {
149149
assert.strictEqual(String(err), 'Error: listen EINVAL');
150150
this.close();

test/parallel/test-net-server-listen-options.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function close() { this.close(); }
1717
.on('listening', common.mustCall(close));
1818
}
1919

20-
// Test listen(port, cb) and listen({port: port}, cb) combinations
20+
// Test listen(port, cb) and listen({ port }, cb) combinations
2121
const listenOnPort = [
2222
(port, cb) => net.createServer().listen({ port }, cb),
2323
(port, cb) => net.createServer().listen(port, cb)

test/parallel/test-stream2-readable-wrap.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const EE = require('events').EventEmitter;
2929
function runTest(highWaterMark, objectMode, produce) {
3030

3131
const old = new EE();
32-
const r = new Readable({ highWaterMark: highWaterMark,
33-
objectMode: objectMode });
32+
const r = new Readable({ highWaterMark, objectMode });
3433
assert.strictEqual(r, r.wrap(old));
3534

3635
r.on('end', common.mustCall());
@@ -63,7 +62,7 @@ function runTest(highWaterMark, objectMode, produce) {
6362
}
6463

6564
const w = new Writable({ highWaterMark: highWaterMark * 2,
66-
objectMode: objectMode });
65+
objectMode });
6766
const written = [];
6867
w._write = function(chunk, encoding, cb) {
6968
written.push(chunk);

test/parallel/test-tls-cert-regression.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ sPWhSOb9VQjMXekI4Y2l8fqAVTS2Fn6+8jkVKxXBywSVCw==
6868

6969
function test(cert, key, cb) {
7070
const server = tls.createServer({
71-
cert: cert,
72-
key: key
71+
cert,
72+
key
7373
}).listen(0, function() {
7474
server.close(cb);
7575
});

test/parallel/test-tls-connect-no-host.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const key = fixtures.readSync('test_key.pem');
1616
// tls.connect(options) with no options.host should accept a cert with
1717
// CN:'localhost'
1818
tls.createServer({
19-
key: key,
20-
cert: cert
19+
key,
20+
cert
2121
}).listen(0, function() {
2222
const socket = tls.connect({
2323
port: this.address().port,

test/parallel/test-tls-ecdh-multiple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ process.on('exit', function() {
7474
unsupportedCurves.push('brainpoolP256r1');
7575

7676
unsupportedCurves.forEach((ecdhCurve) => {
77-
assert.throws(() => tls.createServer({ ecdhCurve: ecdhCurve }),
77+
assert.throws(() => tls.createServer({ ecdhCurve }),
7878
/Error: Failed to set ECDH curve/);
7979
});
8080
});

test/parallel/test-tls-env-extra-ca.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const server = tls.createServer(options, common.mustCall(function(s) {
3838
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'ca1-cert.pem')
3939
});
4040

41-
fork(__filename, { env: env }).on('exit', common.mustCall(function(status) {
41+
fork(__filename, { env }).on('exit', common.mustCall(function(status) {
4242
assert.strictEqual(status, 0, 'client did not succeed in connecting');
4343
}));
4444
}));

test/parallel/test-tls-friendly-error-message.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const tls = require('tls');
3131
const key = fixtures.readKey('agent1-key.pem');
3232
const cert = fixtures.readKey('agent1-cert.pem');
3333

34-
tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) {
34+
tls.createServer({ key, cert }, common.mustCall(function(conn) {
3535
conn.end();
3636
this.close();
3737
})).listen(0, common.mustCall(function() {

test/parallel/test-tls-no-sslv3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fixtures = require('../common/fixtures');
1313

1414
const cert = fixtures.readSync('test_cert.pem');
1515
const key = fixtures.readSync('test_key.pem');
16-
const server = tls.createServer({ cert: cert, key: key }, common.mustNotCall());
16+
const server = tls.createServer({ cert, key }, common.mustNotCall());
1717
const errors = [];
1818
let stderr = '';
1919

test/parallel/test-tls-over-http-tunnel.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ let gotRequest = false;
3535
const key = fixtures.readKey('agent1-key.pem');
3636
const cert = fixtures.readKey('agent1-cert.pem');
3737

38-
const options = {
39-
key: key,
40-
cert: cert
41-
};
38+
const options = { key, cert };
4239

4340
const server = https.createServer(options, function(req, res) {
4441
console.log('SERVER: got request');

test/parallel/test-tls-securepair-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function log(a) {
4242

4343
const server = net.createServer(common.mustCall(function(socket) {
4444
log(`connection fd=${socket.fd}`);
45-
const sslcontext = tls.createSecureContext({ key: key, cert: cert });
45+
const sslcontext = tls.createSecureContext({ key, cert });
4646
sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
4747

4848
const pair = tls.createSecurePair(sslcontext, true);

test/parallel/test-tls-session-cache.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ function doTest(testOptions, callback) {
7171
// Emulate asynchronous store
7272
setTimeout(function() {
7373
assert.ok(!session);
74-
session = {
75-
id: id,
76-
data: data
77-
};
74+
session = { id, data };
7875
cb();
7976
}, 1000);
8077
});

test/parallel/test-tls-starttls-server.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ const server = net.createServer(common.mustCall((s) => {
2121
isServer: true,
2222
server: server,
2323

24-
secureContext: tls.createSecureContext({
25-
key: key,
26-
cert: cert
27-
}),
24+
secureContext: tls.createSecureContext({ key, cert }),
2825

2926
SNICallback: common.mustCall((hostname, callback) => {
3027
assert.strictEqual(hostname, 'test.test');

test/parallel/test-tls-zero-clear-in.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const cert = fixtures.readSync('test_cert.pem');
3232
const key = fixtures.readSync('test_key.pem');
3333

3434
const server = tls.createServer({
35-
cert: cert,
36-
key: key
35+
cert,
36+
key
3737
}, function(c) {
3838
// Nop
3939
setTimeout(function() {

test/parallel/test-util-inspect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ for (const showHidden of [true, false]) {
149149
// Now do the same checks but from a different context
150150
for (const showHidden of [true, false]) {
151151
const ab = vm.runInNewContext('new ArrayBuffer(4)');
152-
const dv = vm.runInNewContext('new DataView(ab, 1, 2)', { ab: ab });
152+
const dv = vm.runInNewContext('new DataView(ab, 1, 2)', { ab });
153153
assert.strictEqual(
154154
util.inspect(ab, showHidden),
155155
'ArrayBuffer { byteLength: 4 }'

test/parallel/test-vm-access-process-env.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const assert = require('assert');
2929
const vm = require('vm');
3030

3131
assert.doesNotThrow(function() {
32-
const context = vm.createContext({ process: process });
32+
const context = vm.createContext({ process });
3333
const result = vm.runInContext('process.env["PATH"]', context);
3434
assert.notStrictEqual(undefined, result);
3535
});

test/parallel/test-vm-context.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const contextifiedSandboxErrorMsg =
8181
script = vm.createScript('const assert = require(\'assert\'); assert.throws(' +
8282
'function() { throw "hello world"; }, /hello/);',
8383
'some.js');
84-
script.runInNewContext({ require: require });
84+
script.runInNewContext({ require });
8585

8686
// Issue GH-7529
8787
script = vm.createScript('delete b');

test/parallel/test-vm-function-declaration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require('../common');
2424
const assert = require('assert');
2525

2626
const vm = require('vm');
27-
const o = vm.createContext({ console: console });
27+
const o = vm.createContext({ console });
2828

2929
// Function declaration and expression should both be copied to the
3030
// sandboxed context.

0 commit comments

Comments
 (0)