wip: tests for compiler compat

This commit is contained in:
Evan You
2021-04-30 15:50:32 -04:00
parent b4c92ccf6b
commit bd3cc4d2c7
9 changed files with 271 additions and 79 deletions

View File

@@ -87,43 +87,6 @@ test('PROPS_DEFAULT_THIS', () => {
).toHaveBeenWarned()
})
test('V_FOR_REF', async () => {
const vm = new Vue({
data() {
return {
ok: true,
list: [1, 2, 3]
}
},
template: `
<template v-if="ok">
<li v-for="i in list" ref="list">{{ i }}</li>
</template>
`
}).$mount() as any
const mapRefs = () => vm.$refs.list.map((el: HTMLElement) => el.textContent)
expect(mapRefs()).toMatchObject(['1', '2', '3'])
expect(deprecationData[DeprecationTypes.V_FOR_REF].message).toHaveBeenWarned()
vm.list.push(4)
await nextTick()
expect(mapRefs()).toMatchObject(['1', '2', '3', '4'])
vm.list.shift()
await nextTick()
expect(mapRefs()).toMatchObject(['2', '3', '4'])
vm.ok = !vm.ok
await nextTick()
expect(mapRefs()).toMatchObject([])
vm.ok = !vm.ok
await nextTick()
expect(mapRefs()).toMatchObject(['2', '3', '4'])
})
test('V_ON_KEYCODE_MODIFIER', () => {
const spy = jest.fn()
const vm = new Vue({