@@ -306,7 +306,7 @@ describe('Component', () => {
306306 expect ( signal ) . toBeDefined ( ) ;
307307 } ) ;
308308
309- it ( 'should handle disconnectedCallback correctly' , ( ) => {
309+ it ( 'should handle disconnectedCallback correctly' , async ( ) => {
310310 const mockTemplate = {
311311 onDestroyed : vi . fn ( ) ,
312312 } ;
@@ -322,6 +322,7 @@ describe('Component', () => {
322322 instance . template = mockTemplate ;
323323
324324 instance . disconnectedCallback ( ) ;
325+ await Promise . resolve ( ) ;
325326
326327 // Instance template's onDestroyed should be called
327328 expect ( mockTemplate . onDestroyed ) . toHaveBeenCalled ( ) ;
@@ -561,7 +562,7 @@ describe('Component', () => {
561562 document . body . appendChild ( el ) ;
562563 await rendered ;
563564 document . body . removeChild ( el ) ;
564- // synchronous in disconnectedCallback
565+ await Promise . resolve ( ) ;
565566 expect ( onDestroyed ) . toHaveBeenCalledTimes ( 1 ) ;
566567 expect ( heard ) . toHaveBeenCalledTimes ( 1 ) ;
567568 } ) ;
@@ -852,6 +853,7 @@ describe('Component', () => {
852853 const signal = el . template . abortSignal ;
853854 expect ( signal . aborted ) . toBe ( false ) ;
854855 document . body . removeChild ( el ) ;
856+ await Promise . resolve ( ) ;
855857 expect ( signal . aborted ) . toBe ( true ) ;
856858 } ) ;
857859 } ) ;
0 commit comments