@@ -240,7 +240,7 @@ describe('SimpleEventPlugin', function() {
240240 } ) ;
241241
242242 // @gate experimental
243- it ( 'flushes pending interactive work before extracting event handler' , ( ) => {
243+ it ( 'flushes pending interactive work before exiting event handler' , ( ) => {
244244 container = document . createElement ( 'div' ) ;
245245 const root = ReactDOM . unstable_createRoot ( container ) ;
246246 document . body . appendChild ( container ) ;
@@ -292,17 +292,14 @@ describe('SimpleEventPlugin', function() {
292292 expect ( Scheduler ) . toHaveYielded ( [
293293 // The handler fired
294294 'Side-effect' ,
295- // but the component did not re-render yet, because it's async
295+ // The component re-rendered synchronously, even in concurrent mode.
296+ 'render button: disabled' ,
296297 ] ) ;
297298
298299 // Click the button again
299300 click ( ) ;
300301 expect ( Scheduler ) . toHaveYielded ( [
301- // Before handling this second click event, the previous interactive
302- // update is flushed
303- 'render button: disabled' ,
304- // The event handler was removed from the button, so there's no second
305- // side-effect
302+ // The event handler was removed from the button, so there's no effect.
306303 ] ) ;
307304
308305 // The handler should not fire again no matter how many times we
@@ -359,8 +356,8 @@ describe('SimpleEventPlugin', function() {
359356
360357 // Click the button a single time
361358 click ( ) ;
362- // The counter should not have updated yet because it's async
363- expect ( button . textContent ) . toEqual ( 'Count: 0 ' ) ;
359+ // The counter should update synchronously, even in concurrent mode.
360+ expect ( button . textContent ) . toEqual ( 'Count: 1 ' ) ;
364361
365362 // Click the button many more times
366363 await TestUtils . act ( async ( ) => {
@@ -442,15 +439,10 @@ describe('SimpleEventPlugin', function() {
442439 button . dispatchEvent ( event ) ;
443440 }
444441
445- // Click the button a single time
446- click ( ) ;
447- // Nothing should flush on the first click.
448- expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
449- // Click again. This will force the previous discrete update to flush. But
450- // only the high-pri count will increase.
442+ // Click the button a single time.
443+ // This will flush at the end of the event, even in concurrent mode.
451444 click ( ) ;
452445 expect ( Scheduler ) . toHaveYielded ( [ 'High-pri count: 1, Low-pri count: 0' ] ) ;
453- expect ( button . textContent ) . toEqual ( 'High-pri count: 1, Low-pri count: 0' ) ;
454446
455447 // Click the button many more times
456448 click ( ) ;
@@ -460,7 +452,7 @@ describe('SimpleEventPlugin', function() {
460452 click ( ) ;
461453 click ( ) ;
462454
463- // Flush the remaining work .
455+ // Each update should synchronously flush, even in concurrent mode .
464456 expect ( Scheduler ) . toHaveYielded ( [
465457 'High-pri count: 2, Low-pri count: 0' ,
466458 'High-pri count: 3, Low-pri count: 0' ,
@@ -470,16 +462,13 @@ describe('SimpleEventPlugin', function() {
470462 'High-pri count: 7, Low-pri count: 0' ,
471463 ] ) ;
472464
473- // Flush the microtask queue
474- await null ;
475-
476- // At the end, both counters should equal the total number of clicks
477- expect ( Scheduler ) . toHaveYielded ( [ 'High-pri count: 8, Low-pri count: 0' ] ) ;
465+ // Now flush the scheduler to apply the transition updates.
466+ // At the end, both counters should equal the total number of clicks.
478467 expect ( Scheduler ) . toFlushAndYield ( [
479- 'High-pri count: 8 , Low-pri count: 8 ' ,
468+ 'High-pri count: 7 , Low-pri count: 7 ' ,
480469 ] ) ;
481470
482- expect ( button . textContent ) . toEqual ( 'High-pri count: 8 , Low-pri count: 8 ' ) ;
471+ expect ( button . textContent ) . toEqual ( 'High-pri count: 7 , Low-pri count: 7 ' ) ;
483472 } ) ;
484473 } ) ;
485474
0 commit comments