add unit tests for `(key,val)` syntax of `v-for`

This commit is contained in:
vprimachenko 2015-10-17 22:32:37 +02:00 committed by Evan You
parent 7e5577cf3e
commit 588d66f73a
1 changed files with 33 additions and 0 deletions

View File

@ -595,6 +595,39 @@ if (_.inBrowser) {
expect(hasWarned(_, 'Duplicate value')).toBe(true)
})
it('key val syntax with object', function () {
new Vue({
el: el,
template: '<div v-for="(key,val) in items">{{key}} {{val}}</div>',
data: {
items: {'a': 'x'}
}
})
expect(el.innerHTML).toBe('<div>a x</div>')
})
it('key val syntax with array', function () {
new Vue({
el: el,
template: '<div v-for="(ind,val) in items">{{ind}} {{val}}</div>',
data: {
items: ['x', 'y']
}
})
expect(el.innerHTML).toBe('<div>0 x</div><div>1 y</div>')
})
it('key val syntax with nested v-for s', function () {
new Vue({
el: el,
template: '<div v-for="(key,val) in items"><div v-for="(subkey,subval) in val">{{key}} {{subkey}} {{subval}}</div></div>',
data: {
items: {'a': {'b': 'c'}}
}
})
expect(el.innerHTML).toBe('<div><div>a b c</div></div>')
})
it('repeat number', function () {
new Vue({
el: el,