Browse Source

test: test case for v-for native collection support

dev
Evan You 6 years ago
parent
commit
d747469e1a
  1. 20
      test/unit/features/directives/for.spec.js

20
test/unit/features/directives/for.spec.js

@ -125,6 +125,26 @@ describe('Directive v-for', () => {
})
if (hasSymbol) {
it('should render native iterables (Map)', () => {
const vm = new Vue({
template: `<div><span v-for="[key, val] in list">{{key}},{{val}}</span></div>`,
data: {
list: new Map([[1, 'foo'], [2, 'bar']])
}
}).$mount()
expect(vm.$el.innerHTML).toBe(`<span>1,foo</span><span>2,bar</span>`)
})
it('should render native iterables (Set)', () => {
const vm = new Vue({
template: `<div><span v-for="val in list">{{val}}</span></div>`,
data: {
list: new Set([1, 2, 3])
}
}).$mount()
expect(vm.$el.innerHTML).toBe(`<span>1</span><span>2</span><span>3</span>`)
})
it('should render iterable of primitive values', done => {
const iterable = {
models: ['a', 'b', 'c'],

Loading…
Cancel
Save