8000 add tests for two-way binding with paths · TonyXY/vue@fdd6d93 · GitHub
[go: up one dir, main page]

Skip to content

Commit fdd6d93

Browse files
committed
add tests for two-way binding with paths
1 parent 60fd14e commit fdd6d93

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/unit/specs/directives/prop_spec.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,44 @@ if (_.inBrowser) {
4646
a: 'A'
4747
}
4848
},
49-
template: '<test testt="{{@test}}" bb="{{@b}}" v-ref="child"></test>',
49+
template: '<test testt="{{@test}}" bb="{{@b}}" a="{{@ test.a }}" v-ref="child"></test>',
5050
components: {
5151
test: {
52-
props: ['testt', 'bb'],
53-
template: '{{testt.a}} {{bb}}'
52+
props: ['testt', 'bb', 'a'],
53+
template: '{{testt.a}} {{bb}} {{a}}'
5454
}
5555
}
5656
})
57-
expect(el.firstChild.textContent).toBe('A B')
57+
expect(el.firstChild.textContent).toBe('A B A')
5858
vm.test.a = 'AA'
5959
vm.b = 'BB'
6060
_.nextTick(function () {
61-
expect(el.firstChild.textContent).toBe('AA BB')
61+
expect(el.firstChild.textContent).toBe('AA BB AA')
6262
vm.test = { a: 'AAA' }
6363
_.nextTick(function () {
64-
expect(el.firstChild.textContent).toBe('AAA BB')
64+
expect(el.firstChild.textContent).toBe('AAA BB AAA')
6565
vm.$data = {
6666
b: 'BBB',
6767
test: {
6868
a: 'AAAA'
6969
}
7070
}
7171
_.nextTick(function () {
72-
expect(el.firstChild.textContent).toBe('AAAA BBB')
72+
expect(el.firstChild.textContent).toBe('AAAA BBB AAAA')
7373
// test two-way
7474
vm.$.child.bb = 'B'
7575
vm.$.child.testt = { a: 'A' }
7676
_.nextTick(function () {
77-
expect(el.firstChild.textContent).toBe('A B')
77+
expect(el.firstChild.textContent).toBe('A B A')
7878
expect(vm.test.a).toBe('A')
7979
expect(vm.test).toBe(vm.$.child.testt)
8080
expect(vm.b).toBe('B')
81-
done()
81+
vm.$.child.a = 'Oops'
82+
_.nextTick(function () {
83+
expect(el.firstChild.textContent).toBe('Oops B Oops')
84+
expect(vm.test.a).toBe('Oops')
85+
done()
86+
})
8287
})
8388
})
8489
})

0 commit comments

Comments
 (0)
0