forked from juliangruber/deep-access
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest.cjs
More file actions
32 lines (24 loc) · 714 Bytes
/
Copy pathtest.cjs
File metadata and controls
32 lines (24 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var test = require('tape');
var deep = require('./index.cjs');
test('deep sets, strict', function (t) {
var obj = {};
t.throws(function () {
deep(obj, 'yep.nope', 'p');
});
deep.p = true;
deep(obj, 'yep.nope', 'p');
t.equal(obj.yep.nope, 'p');
t.end();
});
test.skip('no prototype pollution', function (t) {
const obj = {};
deep(obj, ['__proto__', 'a'], 1);
deep(obj, [['__proto__'], 'b'], 2);
deep(obj, 'constructor.prototype.c', 3);
t.equal(globalThis.a, undefined);
t.equal(globalThis.b, undefined);
t.equal(globalThis.c, undefined);
t.equal(deep(obj, '__proto__.toString'), undefined);
t.equal(deep(obj, 'constructor.prototype.toString'), undefined);
t.end();
});