GeezerVison is showing github.com — test: use `common.mustNotMutateObjectDeep()` in immutability tests · nodejs/node@776cc3a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-fs-options-immutable.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,7 @@ const common = require('../common'); |
9 | 9 | const fs = require('fs'); |
10 | 10 | const path = require('path'); |
11 | 11 |
|
12 | | -const options = Object.freeze({}); |
| 12 | +const options = common.mustNotMutateObjectDeep({}); |
13 | 13 | const tmpdir = require('../common/tmpdir'); |
14 | 14 | tmpdir.refresh(); |
15 | 15 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-https-agent-create-connection.js +3-6Lines changed: 3 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -139,19 +139,16 @@ function createServer() { |
139 | 139 | server.listen(0, common.mustCall(() => { |
140 | 140 | const port = server.address().port; |
141 | 141 | const host = 'localhost'; |
142 | | - const options = { |
| 142 | + const options = common.mustNotMutateObjectDeep({ |
143 | 143 | port: 3000, |
144 | | - rejectUnauthorized: false |
145 | | - }; |
| 144 | + rejectUnauthorized: false, |
| 145 | + }); |
146 | 146 |
|
147 | 147 | const socket = agent.createConnection(port, host, options); |
148 | 148 | socket.on('connect', common.mustCall((data) => { |
149 | 149 | socket.end(); |
150 | 150 | })); |
151 | 151 | socket.on('end', common.mustCall(() => { |
152 | | - assert.deepStrictEqual(options, { |
153 | | - port: 3000, rejectUnauthorized: false |
154 | | - }); |
155 | 152 | server.close(); |
156 | 153 | })); |
157 | 154 | })); |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-https-argument-of-creating.js +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,11 +12,13 @@ const dftProtocol = {}; |
12 | 12 |
|
13 | 13 | // Test for immutable `opts` |
14 | 14 | { |
15 | | - const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] }; |
| 15 | + const opts = common.mustNotMutateObjectDeep({ |
| 16 | + foo: 'bar', |
| 17 | + ALPNProtocols: [ 'http/1.1' ], |
| 18 | + }); |
16 | 19 | const server = https.createServer(opts); |
17 | 20 |
|
18 | 21 | tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol); |
19 | | - assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] }); |
20 | 22 | assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols), |
21 | 23 | 0); |
22 | 24 | } |
|