master
1describe "csx.Proxy", ->
2 subject = null
3
4 describe "#create", ->
5 object = null
6 subject = csx.Proxy
7
8 beforeEach ->
9 object =
10 top: 'one'
11 more:
12 stuff: ['a','b']
13
14 it 'gets the value of a shallow object reference', ->
15 expect(subject.create(object, 'top')).toEqual(object.top)
16
17 it 'gets the value of a deep object reference', ->
18 expect(subject.create(object, 'more.stuff')).toEqual(object.more.stuff)
19
20 it 'sets the value of a shallow object reference', ->
21 subject.create(object, 'top', 'two')
22 expect(object.top).toEqual('two')
23
24 it 'sets the value of a deep object reference', ->
25 subject.create(object, 'more.stuff', 5)
26 expect(object.more.stuff).toEqual(5)
27
28 it "returns undefined if a reference doesn't exist", ->
29 expect(subject.create(object, 'non.existent.path')).toEqual(undefined)