Skip to content

Commit 776cc3a

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

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const common = require('../common');
99
constfs=require('fs');
1010
constpath=require('path');
1111

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

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

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

147147
constsocket=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‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ const dftProtocol ={};
1212

1313
// Test for immutable `opts`
1414
{
15-
constopts={foo: 'bar',ALPNProtocols: ['http/1.1']};
15+
constopts=common.mustNotMutateObjectDeep({
16+
foo: 'bar',
17+
ALPNProtocols: ['http/1.1'],
18+
});
1619
constserver=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)