Хочу проверить на выполнение метода handleApprove после клика и выполнения emit-a.
component:
<q-btn
data-test="approveBtn"
@click.prevent="handleApprove"
/>
...
handleApprove () {
this.$emit('ok')
this.hide()
},
test:
...
it ('Is emitted', async () => {
const approveBtn = wrapper.find('[data-test="approveBtn"]')
const handleApprove = wrapper.vm.$emit('ok')
wrapper.vm.handleApprove = handleApprove
expect(approveBtn.exists()).toBe(true)
// await approveBtn.trigger('click')
expect(wrapper.emitted('ok')).toBeTruthy()
// expect(wrapper.vm.onOKClick).toHaveBeenCalled()
expect(wrapper.emitted()).toHaveProperty('ok')
})
...
Должно рабоать так:
it ('Is emitted', async () => {
const approveBtn = wrapper.find('[data-test="approveBtn"]')
await approveBtn.trigger('click')
expect(wrapper.emitted()).toHaveProperty('ok')
})
Но получаю ошибку:
expect(received).toHaveProperty(path)
Expected path: "ok"
Received path: []
Received value: {}