Skip to content

Commit 1acd0e4

Browse files
committed
tests: failing test case
1 parent a6a50c7 commit 1acd0e4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tests/emit.spec.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ describe('emitted', () => {
2222
expect(wrapper.emitted().hello[1]).toEqual(['foo', 'bar'])
2323
})
2424

25-
// NOTE: This will fail until alpha 5.
26-
// For now I am testing this by hacking node_modules/vue/dist/vue.esm.js with the following fix:
27-
// https://github.com/vuejs/vue-next/commit/e308ad99e9f5bdfb0910a2d6959e746f558714c5
2825
it('captures events emitted via ctx.emit', () => {
2926
const Component = defineComponent({
3027
name: 'ContextEmit',
@@ -46,4 +43,26 @@ describe('emitted', () => {
4643
wrapper.find('button').trigger('click')
4744
expect(wrapper.emitted().hello[1]).toEqual(['foo', 'bar'])
4845
})
46+
47+
it.only('captures events emitted via destructured emit', () => {
48+
const Component = defineComponent({
49+
name: 'ContextEmit',
50+
51+
setup(props, { emit }) {
52+
return () =>
53+
h('div', [
54+
h('button', { onClick: () => emit('hello', 'foo', 'bar') })
55+
])
56+
}
57+
})
58+
const wrapper = mount(Component)
59+
expect(wrapper.emitted()).toEqual({})
60+
expect(wrapper.emitted().hello).toEqual(undefined)
61+
62+
wrapper.find('button').trigger('click')
63+
expect(wrapper.emitted().hello[0]).toEqual(['foo', 'bar'])
64+
65+
wrapper.find('button').trigger('click')
66+
expect(wrapper.emitted().hello[1]).toEqual(['foo', 'bar'])
67+
})
4968
})

0 commit comments

Comments
 (0)