Skip to content

Commit 9432f38

Browse files
committed
refactor(harden): Adapt shallow make-hardener test
1 parent bc2ad3e commit 9432f38

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/harden/test/make-hardener-shallow.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { makeHardener } from '../make-hardener.js';
66
const { stringify: q } = JSON;
77

88
test('makeHardener', t => {
9-
const h = makeHardener({ traversePrototypes: true });
9+
const h = makeHardener({ traversePrototypes: false });
1010
const o = { a: {} };
1111
t.is(h(o), o);
1212
t.true(Object.isFrozen(o));
1313
t.true(Object.isFrozen(o.a));
1414
});
1515

1616
test('harden the same thing twice', t => {
17-
const h = makeHardener({ traversePrototypes: true });
17+
const h = makeHardener({ traversePrototypes: false });
1818
const o = { a: {} };
1919
t.is(h(o), o);
2020
t.is(h(o), o);
@@ -23,7 +23,7 @@ test('harden the same thing twice', t => {
2323
});
2424

2525
test('harden objects with cycles', t => {
26-
const h = makeHardener({ traversePrototypes: true });
26+
const h = makeHardener({ traversePrototypes: false });
2727
const o = { a: {} };
2828
o.a.foo = o;
2929
t.is(h(o), o);
@@ -32,7 +32,7 @@ test('harden objects with cycles', t => {
3232
});
3333

3434
test('harden overlapping objects', t => {
35-
const h = makeHardener({ traversePrototypes: true });
35+
const h = makeHardener({ traversePrototypes: false });
3636
const o1 = { a: {} };
3737
const o2 = { a: o1.a };
3838
t.is(h(o1), o1);
@@ -43,18 +43,18 @@ test('harden overlapping objects', t => {
4343
t.true(Object.isFrozen(o2));
4444
});
4545

46-
test('harden up prototype chain', t => {
47-
const h = makeHardener({ traversePrototypes: true });
46+
test('do not harden up prototype chain', t => {
47+
const h = makeHardener({ traversePrototypes: false });
4848
const a = { a: 1 };
4949
const b = { b: 1, __proto__: a };
5050
const c = { c: 1, __proto__: b };
5151

5252
h(c);
53-
t.true(Object.isFrozen(a));
53+
t.false(Object.isFrozen(a));
5454
});
5555

5656
test('harden tolerates objects with null prototypes', t => {
57-
const h = makeHardener({ traversePrototypes: true });
57+
const h = makeHardener({ traversePrototypes: false });
5858
const o = { a: 1 };
5959
Object.setPrototypeOf(o, null);
6060
t.is(h(o), o);
@@ -78,7 +78,7 @@ test('harden typed arrays', t => {
7878
];
7979

8080
for (const TypedArray of typedArrayConstructors) {
81-
const h = makeHardener({ traversePrototypes: true });
81+
const h = makeHardener({ traversePrototypes: false });
8282
const a = new TypedArray(1);
8383

8484
t.is(h(a), a, `harden ${TypedArray}`);
@@ -106,7 +106,7 @@ test('harden typed arrays', t => {
106106
});
107107

108108
test('harden typed arrays and their expandos', t => {
109-
const h = makeHardener({ traversePrototypes: true });
109+
const h = makeHardener({ traversePrototypes: false });
110110
const a = new Uint8Array(1);
111111
const b = new Uint8Array(1);
112112

@@ -239,7 +239,7 @@ test('harden typed arrays and their expandos', t => {
239239
});
240240

241241
test('hardening makes writable properties readonly even if non-configurable', t => {
242-
const h = makeHardener({ traversePrototypes: true });
242+
const h = makeHardener({ traversePrototypes: false });
243243
const o = {};
244244
Object.defineProperty(o, 'x', {
245245
value: 10,
@@ -258,7 +258,7 @@ test('hardening makes writable properties readonly even if non-configurable', t
258258
});
259259

260260
test('harden a typed array with a writable non-configurable expando', t => {
261-
const h = makeHardener({ traversePrototypes: true });
261+
const h = makeHardener({ traversePrototypes: false });
262262
const a = new Uint8Array(1);
263263
Object.defineProperty(a, 'x', {
264264
value: 'A',
@@ -282,14 +282,14 @@ test('harden a typed array with a writable non-configurable expando', t => {
282282
});
283283

284284
test('harden a typed array subclass', t => {
285-
const h = makeHardener({ traversePrototypes: true });
285+
const h = makeHardener({ traversePrototypes: false });
286286

287287
class Ooint8Array extends Uint8Array {
288288
oo = 'ghosts';
289289
}
290290
h(Ooint8Array);
291291
t.true(Object.isFrozen(Ooint8Array.prototype));
292-
t.true(Object.isFrozen(Object.getPrototypeOf(Ooint8Array.prototype)));
292+
t.false(Object.isFrozen(Object.getPrototypeOf(Ooint8Array.prototype)));
293293

294294
const a = new Ooint8Array(1);
295295
t.is(h(a), a);

0 commit comments

Comments
 (0)