Skip to content

Commit cca269c

Browse files
dericoptargos
authored andcommitted
test: use template strings in parallel tests
PR-URL: #32549 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 62db9a0 commit cca269c

7 files changed

+22
-22
lines changed

test/parallel/test-buffer-bigint64.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,49 @@ const buf = Buffer.allocUnsafe(8);
77
['LE', 'BE'].forEach(function(endianness) {
88
// Should allow simple BigInts to be written and read
99
let val = 123456789n;
10-
buf['writeBigInt64' + endianness](val, 0);
11-
let rtn = buf['readBigInt64' + endianness](0);
10+
buf[`writeBigInt64${endianness}`](val, 0);
11+
let rtn = buf[`readBigInt64${endianness}`](0);
1212
assert.strictEqual(val, rtn);
1313

1414
// Should allow INT64_MAX to be written and read
1515
val = 0x7fffffffffffffffn;
16-
buf['writeBigInt64' + endianness](val, 0);
17-
rtn = buf['readBigInt64' + endianness](0);
16+
buf[`writeBigInt64${endianness}`](val, 0);
17+
rtn = buf[`readBigInt64${endianness}`](0);
1818
assert.strictEqual(val, rtn);
1919

2020
// Should read and write a negative signed 64-bit integer
2121
val = -123456789n;
22-
buf['writeBigInt64' + endianness](val, 0);
23-
assert.strictEqual(val, buf['readBigInt64' + endianness](0));
22+
buf[`writeBigInt64${endianness}`](val, 0);
23+
assert.strictEqual(val, buf[`readBigInt64${endianness}`](0));
2424

2525
// Should read and write an unsigned 64-bit integer
2626
val = 123456789n;
27-
buf['writeBigUInt64' + endianness](val, 0);
28-
assert.strictEqual(val, buf['readBigUInt64' + endianness](0));
27+
buf[`writeBigUInt64${endianness}`](val, 0);
28+
assert.strictEqual(val, buf[`readBigUInt64${endianness}`](0));
2929

3030
// Should throw a RangeError upon INT64_MAX+1 being written
3131
assert.throws(function() {
3232
const val = 0x8000000000000000n;
33-
buf['writeBigInt64' + endianness](val, 0);
33+
buf[`writeBigInt64${endianness}`](val, 0);
3434
}, RangeError);
3535

3636
// Should throw a RangeError upon UINT64_MAX+1 being written
3737
assert.throws(function() {
3838
const val = 0x10000000000000000n;
39-
buf['writeBigUInt64' + endianness](val, 0);
39+
buf[`writeBigUInt64${endianness}`](val, 0);
4040
}, {
4141
code: 'ERR_OUT_OF_RANGE',
4242
message: 'The value of "value" is out of range. It must be ' +
43-
'>= 0n and < 2n ** 64n. Received 18_446_744_073_709_551_616n'
43+
'>= 0n and < 2n ** 64n. Received 18_446_744_073_709_551_616n'
4444
});
4545

4646
// Should throw a TypeError upon invalid input
4747
assert.throws(function() {
48-
buf['writeBigInt64' + endianness]('bad', 0);
48+
buf[`writeBigInt64${endianness}`]('bad', 0);
4949
}, TypeError);
5050

5151
// Should throw a TypeError upon invalid input
5252
assert.throws(function() {
53-
buf['writeBigUInt64' + endianness]('bad', 0);
53+
buf[`writeBigUInt64${endianness}`]('bad', 0);
5454
}, TypeError);
5555
});

test/parallel/test-http-readable-data-event.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ let next = null;
1010

1111
const server = http.createServer((req, res) => {
1212
res.writeHead(200, {
13-
'Content-Length': '' + (helloWorld.length + helloAgainLater.length)
13+
'Content-Length': `${(helloWorld.length + helloAgainLater.length)}`
1414
});
1515

1616
// We need to make sure the data is flushed
1717
// before writing again
1818
next = () => {
1919
res.end(helloAgainLater);
20-
next = () => {};
20+
next = () => { };
2121
};
2222

2323
res.write(helloWorld);

test/parallel/test-http2-origin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
7070
}
7171
);
7272
});
73-
const longInput = 'http://foo.bar' + 'a'.repeat(16383);
73+
const longInput = `http://foo.bar${'a'.repeat(16383)}`;
7474
throws(
7575
() => session.origin(longInput),
7676
{
@@ -107,7 +107,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
107107

108108
// Test automatically sending origin on connection start
109109
{
110-
const origins = [ 'https://foo.org/a/b/c', 'https://bar.org' ];
110+
const origins = ['https://foo.org/a/b/c', 'https://bar.org'];
111111
const server = createSecureServer({ key, cert, origins });
112112
server.on('stream', mustCall((stream) => {
113113
stream.respond();

test/parallel/test-http2-server-session-destroy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ server.listen(0, common.localhostIPv4, common.mustCall(() => {
1616

1717
const port = server.address().port;
1818
const host = common.localhostIPv4;
19-
h2.connect('http://' + host + ':' + port, afterConnect);
19+
h2.connect(`http://${host}:${port}`, afterConnect);
2020
}));

test/parallel/test-promises-warning-on-unhandled-rejection.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ process.on('warning', common.mustCall((warning) => {
2323
assert(
2424
/Unhandled promise rejection/.test(warning.message),
2525
'Expected warning message to contain "Unhandled promise rejection" ' +
26-
'but did not. Had "' + warning.message + '" instead.'
26+
`but did not. Had "${warning.message}" instead.`
2727
);
2828
break;
2929
case 2:
@@ -40,7 +40,7 @@ process.on('warning', common.mustCall((warning) => {
4040
assert(
4141
/Unhandled promise rejection/.test(warning.message),
4242
'Expected warning message to contain "Unhandled promise rejection" ' +
43-
'but did not. Had "' + warning.message + '" instead.'
43+
`but did not. Had "${warning.message}" instead.`
4444
);
4545
break;
4646
case 5:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let gotWorld = false;
4343
server.listen(0, () => {
4444
const client = spawn(common.opensslCli, [
4545
's_client',
46-
'-connect', '127.0.0.1:' + server.address().port,
46+
'-connect', `127.0.0.1:${server.address().port}`,
4747
'-cipher', CIPHERS,
4848
'-psk', KEY,
4949
'-psk_identity', IDENTITY

test/parallel/test-worker-relative-path.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const assert = require('assert');
55
const { Worker, isMainThread, parentPort } = require('worker_threads');
66

77
if (isMainThread) {
8-
const w = new Worker('./' + path.relative('.', __filename));
8+
const w = new Worker(`./${path.relative('.', __filename)}`);
99
w.on('message', common.mustCall((message) => {
1010
assert.strictEqual(message, 'Hello, world!');
1111
}));

0 commit comments

Comments
 (0)