defineComponent,
h,
nodeOps,
- toHandlers
+ toHandlers,
+ nextTick
} from '@vue/runtime-test'
import { isEmitListener } from '../src/componentEmits'
// PascalCase option
expect(isEmitListener(options, 'onFooBaz')).toBe(true)
})
+
+ test('does not emit after unmount', async () => {
+ const fn = jest.fn()
+ const Foo = defineComponent({
+ emits: ['closing'],
+ async beforeUnmount() {
+ await this.$nextTick()
+ this.$emit('closing', true)
+ },
+ render() {
+ return h('div')
+ }
+ })
+ const Comp = () =>
+ h(Foo, {
+ onClosing: fn
+ })
+
+ const el = nodeOps.createElement('div')
+ render(h(Comp), el)
+ await nextTick()
+ render(null, el)
+ await nextTick()
+ expect(fn).not.toHaveBeenCalled()
+ })
})