File tree 1 file changed +33
-2
lines changed
packages/runtime-vapor/__tests__
1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 3
3
// Note: emits and listener fallthrough is tested in
4
4
// ./rendererAttrsFallthrough.spec.ts.
5
5
6
- import { defineComponent , render } from '../src'
6
+ import {
7
+ defineComponent ,
8
+ nextTick ,
9
+ onBeforeUnmount ,
10
+ render ,
11
+ unmountComponent ,
12
+ } from '../src'
7
13
import { isEmitListener } from '../src/componentEmits'
8
14
9
15
let host : HTMLElement
@@ -443,7 +449,32 @@ describe('component: emit', () => {
443
449
expect ( isEmitListener ( options , 'onFooBaz' ) ) . toBe ( true )
444
450
} )
445
451
446
- test . todo ( 'does not emit after unmount' , async ( ) => { } )
452
+ test ( 'does not emit after unmount' , async ( ) => {
453
+ const fn = vi . fn ( )
454
+ const Foo = defineComponent ( {
455
+ emits : [ 'closing' ] ,
456
+ setup ( _ : any , { emit } : any ) {
457
+ onBeforeUnmount ( async ( ) => {
458
+ await nextTick ( )
459
+ emit ( 'closing' , true )
460
+ } )
461
+ } ,
462
+ render ( ) { } ,
463
+ } )
464
+ const i = render (
465
+ Foo ,
466
+ {
467
+ get onClosing ( ) {
468
+ return fn
469
+ } ,
470
+ } ,
471
+ '#host' ,
472
+ )
473
+ await nextTick ( )
474
+ unmountComponent ( i )
475
+ await nextTick ( )
476
+ expect ( fn ) . not . toHaveBeenCalled ( )
477
+ } )
447
478
448
479
test . todo ( 'merge string array emits' , async ( ) => { } )
449
480
You can’t perform that action at this time.
0 commit comments