forked from dawidd6/action-download-artifact
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove.js
More file actions
70 lines (56 loc) · 1.63 KB
/
Copy pathmove.js
File metadata and controls
70 lines (56 loc) · 1.63 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
64
65
66
67
68
69
70
'use strict'
require('should')
var Dot = require('../index')
describe('Move test:', function () {
it('Should be able to move properties', function () {
var link = {
id: '527423a65e380f0000588e47',
source: '526dd5c6b4c4aa8770000001',
target: '527402d6b15d1800008755cf',
out: 'github',
in: 'in'
}
var expected = {
id: '527423a65e380f0000588e47',
source: { id: '526dd5c6b4c4aa8770000001', port: 'github' },
target: { id: '527402d6b15d1800008755cf', port: 'in' }
}
Dot.move('source', 'source.id', link)
Dot.move('out', 'source.port', link)
Dot.move('target', 'target.id', link)
Dot.move('in', 'target.port', link)
link.should.eql(expected)
})
it('Undefined properties should be ignored', function () {
var link = {
source: '526dd5c6b4c4aa8770000001',
target: '527402d6b15d1800008755cf',
out: 'github',
in: 'in'
}
var expected = {
source: { id: '526dd5c6b4c4aa8770000001' },
target: { port: 'in' },
out: 'github'
}
Dot.move('source', 'source.id', link)
Dot.move('out.er.nope', 'source.port', link)
Dot.move('target.bla.di.bla', 'target.id', link)
Dot.move('in', 'target.port', link)
link.should.eql(expected)
})
it('Should process modifiers', function () {
var link = {
source: 'one',
target: 'two'
}
var expected = {
source: { id: 'ONE' },
target: { port: 'TWO' }
}
function up (val) { return val.toUpperCase() }
Dot.move('source', 'source.id', link, up)
Dot.move('target', 'target.port', link, up)
link.should.eql(expected)
})
})