mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test: use common.mustNotMutateObjectDeep() in immutability tests
PR-URL: https://github.com/nodejs/node/pull/43196 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
409158c919
commit
e271e3403e
3 files changed
+8
-9
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
}));
|
||||
}));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user