Skip to content

Commit

Permalink
test: use common.mustNotMutateObjectDeep() in immutability tests
Browse files Browse the repository at this point in the history
PR-URL: #43196
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
LiviaMedeiros authored and targos committed Jul 31, 2022
1 parent 409158c commit e271e34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-fs-options-immutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const common = require('../common');
const fs = require('fs');
const path = require('path');

const options = Object.freeze({});
const options = common.mustNotMutateObjectDeep({});
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

Expand Down
9 changes: 3 additions & 6 deletions test/parallel/test-https-agent-create-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,16 @@ function createServer() {
server.listen(0, common.mustCall(() => {
const port = server.address().port;
const host = 'localhost';
const options = {
const options = common.mustNotMutateObjectDeep({
port: 3000,
rejectUnauthorized: false
};
rejectUnauthorized: false,
});

const socket = agent.createConnection(port, host, options);
socket.on('connect', common.mustCall((data) => {
socket.end();
}));
socket.on('end', common.mustCall(() => {
assert.deepStrictEqual(options, {
port: 3000, rejectUnauthorized: false
});
server.close();
}));
}));
Expand Down
6 changes: 4 additions & 2 deletions test/parallel/test-https-argument-of-creating.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ const dftProtocol = {};

// Test for immutable `opts`
{
const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] };
const opts = common.mustNotMutateObjectDeep({
foo: 'bar',
ALPNProtocols: [ 'http/1.1' ],
});
const server = https.createServer(opts);

tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] });
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
}
Expand Down

0 comments on commit e271e34

Please sign in to comment.