Skip to content

Commit d747469

Browse files
committed
test: test case for v-for native collection support
1 parent 7a92904 commit d747469

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

+20
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,26 @@ describe('Directive v-for', () => {
125125
})
126126

127127
if (hasSymbol) {
128+
it('should render native iterables (Map)', () => {
129+
const vm = new Vue({
130+
template: `<div><span v-for="[key, val] in list">{{key}},{{val}}</span></div>`,
131+
data: {
132+
list: new Map([[1, 'foo'], [2, 'bar']])
133+
}
134+
}).$mount()
135+
expect(vm.$el.innerHTML).toBe(`<span>1,foo</span><span>2,bar</span>`)
136+
})
137+
138+
it('should render native iterables (Set)', () => {
139+
const vm = new Vue({
140+
template: `<div><span v-for="val in list">{{val}}</span></div>`,
141+
data: {
142+
list: new Set([1, 2, 3])
143+
}
144+
}).$mount()
145+
expect(vm.$el.innerHTML).toBe(`<span>1</span><span>2</span><span>3</span>`)
146+
})
147+
128148
it('should render iterable of primitive values', done => {
129149
const iterable = {
130150
models: ['a', 'b', 'c'],

0 commit comments

Comments
 (0)