@@ -22,9 +22,6 @@ describe('emitted', () => {
22
22
expect ( wrapper . emitted ( ) . hello [ 1 ] ) . toEqual ( [ 'foo' , 'bar' ] )
23
23
} )
24
24
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
28
25
it ( 'captures events emitted via ctx.emit' , ( ) => {
29
26
const Component = defineComponent ( {
30
27
name : 'ContextEmit' ,
@@ -46,4 +43,26 @@ describe('emitted', () => {
46
43
wrapper . find ( 'button' ) . trigger ( 'click' )
47
44
expect ( wrapper . emitted ( ) . hello [ 1 ] ) . toEqual ( [ 'foo' , 'bar' ] )
48
45
} )
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
+ } )
49
68
} )
0 commit comments