forked from dawidd6/action-download-artifact
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstr.js
More file actions
63 lines (56 loc) · 1.17 KB
/
Copy pathstr.js
File metadata and controls
63 lines (56 loc) · 1.17 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict'
require('should')
var Dot = require('../index')
describe('str:', function () {
it('can set root property', function () {
Dot.str('b', 2, {
a: 1
}).should.deepEqual({
a: 1,
b: 2
})
})
it('can set nested property', function () {
Dot.str('b.a', 2, {
a: 1
}).should.deepEqual({
a: 1,
b: {
a: 2
}
})
})
it('can set nested with array notation', function () {
var obj = {
a: 1
}
Dot.str('object.fields[0].subfield', 'value', obj)
Dot.str('object.fields[1].subfield', 'value1', obj)
obj.should.deepEqual({
a: 1,
object: {
fields: [
{
subfield: 'value'
},
{
subfield: 'value1'
}
]
}
})
})
it('can set root level property regardless whether override is set', function () {
Dot.str('a', 'b', {
a: 1
}).should.deepEqual({
a: 'b'
})
})
it('cannot set __proto__ property', function () {
(() => Dot.str('__proto__.toString', 'hi', {})).should.throw(
/Refusing to update/
);
({}.toString().should.deepEqual('[object Object]'))
})
})