From e271e3403e6408782e71f957207bedb202cf8bc0 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Wed, 13 Jul 2022 01:57:37 +0800 Subject: [PATCH] test: use `common.mustNotMutateObjectDeep()` in immutability tests PR-URL: https://github.com/nodejs/node/pull/43196 Reviewed-By: Darshan Sen Reviewed-By: Antoine du Hamel --- test/parallel/test-fs-options-immutable.js | 2 +- test/parallel/test-https-agent-create-connection.js | 9 +++------ test/parallel/test-https-argument-of-creating.js | 6 ++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-fs-options-immutable.js b/test/parallel/test-fs-options-immutable.js index 77ce3ebf1de9ca..dfe05a96ef7c3b 100644 --- a/test/parallel/test-fs-options-immutable.js +++ b/test/parallel/test-fs-options-immutable.js @@ -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(); diff --git a/test/parallel/test-https-agent-create-connection.js b/test/parallel/test-https-agent-create-connection.js index cea335a422ebc7..1ac2c840b0d5e2 100644 --- a/test/parallel/test-https-agent-create-connection.js +++ b/test/parallel/test-https-agent-create-connection.js @@ -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(); })); })); diff --git a/test/parallel/test-https-argument-of-creating.js b/test/parallel/test-https-argument-of-creating.js index 6f1564826eaf74..fe6ca9f59a6adc 100644 --- a/test/parallel/test-https-argument-of-creating.js +++ b/test/parallel/test-https-argument-of-creating.js @@ -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); }