Skip to content

Commit 776cc3a

Browse files
LiviaMedeirosdanielleadams
authored andcommitted
test: use common.mustNotMutateObjectDeep() in immutability tests
PR-URL: #43196 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 42f2deb commit 776cc3a

3 files changed

+8
-9
lines changed

test/parallel/test-fs-options-immutable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const common = require('../common');
99
const fs = require('fs');
1010
const path = require('path');
1111

12-
const options = Object.freeze({});
12+
const options = common.mustNotMutateObjectDeep({});
1313
const tmpdir = require('../common/tmpdir');
1414
tmpdir.refresh();
1515

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,16 @@ function createServer() {
139139
server.listen(0, common.mustCall(() => {
140140
const port = server.address().port;
141141
const host = 'localhost';
142-
const options = {
142+
const options = common.mustNotMutateObjectDeep({
143143
port: 3000,
144-
rejectUnauthorized: false
145-
};
144+
rejectUnauthorized: false,
145+
});
146146

147147
const socket = agent.createConnection(port, host, options);
148148
socket.on('connect', common.mustCall((data) => {
149149
socket.end();
150150
}));
151151
socket.on('end', common.mustCall(() => {
152-
assert.deepStrictEqual(options, {
153-
port: 3000, rejectUnauthorized: false
154-
});
155152
server.close();
156153
}));
157154
}));

test/parallel/test-https-argument-of-creating.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ const dftProtocol = {};
1212

1313
// Test for immutable `opts`
1414
{
15-
const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] };
15+
const opts = common.mustNotMutateObjectDeep({
16+
foo: 'bar',
17+
ALPNProtocols: [ 'http/1.1' ],
18+
});
1619
const server = https.createServer(opts);
1720

1821
tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
19-
assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] });
2022
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
2123
0);
2224
}

0 commit comments

Comments
 (0)