-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathlush_extends_spec.moon
49 lines (39 loc) · 1.18 KB
/
lush_extends_spec.moon
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
describe "lush", ->
lush = require('lush')
it "should pass to parse(spec, {extends: ...})", ->
parent = lush(-> {
A { fg: "a_fg" }
})
child = lush((-> {
B { A }
}), {extends: {parent}})
assert.is_equal(child.B.fg, parent.A.fg)
it "extends(parent).with(spec)", ->
parent = lush(-> {
A { fg: "a_fg" }
})
child = lush.extend(parent).with(-> { B { A } })
assert.is_equal(child.B.fg, parent.A.fg)
it "can chain extends", ->
parent = lush(-> {
A { fg: "a_fg" }
})
other = lush(-> {
C { fg: "c_fg" }
})
child = lush.extend(parent).extend(other).with(-> { B { A } })
assert.is_equal(child.B.fg, parent.A.fg)
assert.is_equal(child.C.fg, other.C.fg)
it "accepts any number of parents", ->
parent = lush(-> {
A { fg: "a_fg" }
})
other = lush(-> {
C { fg: "c_fg" }
})
child = lush.extend(parent, other).with(-> { B { A } })
assert.is_equal(child.B.fg, parent.A.fg)
assert.is_equal(child.C.fg, other.C.fg)
child = lush.extend(unpack({parent, other})).with(-> { B { A } })
assert.is_equal(child.B.fg, parent.A.fg)
assert.is_equal(child.C.fg, other.C.fg)