File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ it("block prop types", () => {
104104 }
105105} ) ;
106106
107- it ( "onMount and onUnmount" , ( ) => {
107+ it ( "onMount and onUnmount" , async ( ) => {
108108 const editor = BlockNoteEditor . create ( ) ;
109109 let mounted = false ;
110110 let unmounted = false ;
@@ -118,6 +118,10 @@ it("onMount and onUnmount", () => {
118118 expect ( mounted ) . toBe ( true ) ;
119119 expect ( unmounted ) . toBe ( false ) ;
120120 editor . unmount ( ) ;
121+ // expect the unmount event to not have been triggered yet, since it waits 2 ticks
122+ expect ( unmounted ) . toBe ( false ) ;
123+ // wait 3 ticks to ensure the unmount event is triggered
124+ await new Promise ( ( resolve ) => setTimeout ( resolve , 3 ) ) ;
121125 expect ( mounted ) . toBe ( true ) ;
122126 expect ( unmounted ) . toBe ( true ) ;
123127} ) ;
You can’t perform that action at this time.
0 commit comments