test: test for events when component updating (#7896)

test for #5517
This commit is contained in:
iwusong 2024-06-04 23:04:11 +08:00 committed by GitHub
parent 4caabf2cb7
commit be1e9bf03f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 0 deletions

View File

@ -749,4 +749,39 @@ describe('component props', () => {
expect(`Invalid prop name: "ref"`).toHaveBeenWarned()
expect(`Invalid prop name: "$foo"`).toHaveBeenWarned()
})
// #5517
test('events should not be props when component updating', async () => {
let props: any
function eventHandler() {}
const foo = ref(1)
const Child = defineComponent({
setup(_props) {
props = _props
},
emits: ['event'],
props: ['foo'],
template: `<div>{{ foo }}</div>`,
})
const Comp = defineComponent({
setup() {
return {
foo,
eventHandler,
}
},
components: { Child },
template: `<Child @event="eventHandler" :foo="foo" />`,
})
const root = document.createElement('div')
domRender(h(Comp), root)
expect(props).not.toHaveProperty('onEvent')
foo.value++
await nextTick()
expect(props).not.toHaveProperty('onEvent')
})
})