test(runtime-core): test multi-root ref assignment (#1374)

This commit is contained in:
Carlos Rodrigues 2020-06-15 14:31:14 +01:00 committed by GitHub
parent 79686e90e2
commit 6e9789cef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,4 +218,32 @@ describe('api: template refs', () => {
render(h(Comp), root)
expect(state.refKey).toBe(root.children[0])
})
test('multiple root refs', () => {
const root = nodeOps.createElement('div')
const refKey1 = ref(null)
const refKey2 = ref(null)
const refKey3 = ref(null)
const Comp = {
setup() {
return {
refKey1,
refKey2,
refKey3
}
},
render() {
return [
h('div', { ref: 'refKey1' }),
h('div', { ref: 'refKey2' }),
h('div', { ref: 'refKey3' })
]
}
}
render(h(Comp), root)
expect(refKey1.value).toBe(root.children[1])
expect(refKey2.value).toBe(root.children[2])
expect(refKey3.value).toBe(root.children[3])
})
})