test: add tests

This commit is contained in:
daiwei 2025-01-21 10:57:07 +08:00
parent b9cd226d23
commit e4208e452d
1 changed files with 22 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import {
h,
nextTick,
nodeOps,
onMounted,
ref,
render,
useTemplateRef,
@ -125,4 +126,25 @@ describe('useTemplateRef', () => {
__DEV__ = true
}
})
// #12749
test(`don't update setup ref for useTemplateRef key`, () => {
let foo: ShallowRef
const Comp = {
setup() {
foo = useTemplateRef('bar')
const bar = ref(null)
onMounted(() => {
expect(bar.value).toBe(null)
})
return { bar }
},
render() {
return h('div', { ref: 'bar' })
},
}
const root = nodeOps.createElement('div')
render(h(Comp), root)
expect(foo!.value).toBe(root.children[0])
})
})