@@ -18,6 +18,8 @@ describe('SimpleEventPlugin', function () {
1818
1919 let onClick ;
2020 let container ;
21+ let assertLog ;
22+ let waitForAll ;
2123
2224 function expectClickThru ( element ) {
2325 element . click ( ) ;
@@ -43,6 +45,10 @@ describe('SimpleEventPlugin', function () {
4345 ReactDOMClient = require ( 'react-dom/client' ) ;
4446 Scheduler = require ( 'scheduler' ) ;
4547
48+ const InternalTestUtils = require ( 'internal-test-utils' ) ;
49+ assertLog = InternalTestUtils . assertLog ;
50+ waitForAll = InternalTestUtils . waitForAll ;
51+
4652 onClick = jest . fn ( ) ;
4753 } ) ;
4854
@@ -222,12 +228,12 @@ describe('SimpleEventPlugin', function () {
222228
223229 ReactDOM . render ( < Button /> , container ) ;
224230 expect ( button . textContent ) . toEqual ( 'Count: 0' ) ;
225- expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
231+ assertLog ( [ ] ) ;
226232
227233 click ( ) ;
228234
229235 // There should be exactly one update.
230- expect ( Scheduler ) . toHaveYielded ( [ 'didUpdate - Count: 3' ] ) ;
236+ assertLog ( [ 'didUpdate - Count: 3' ] ) ;
231237 expect ( button . textContent ) . toEqual ( 'Count: 3' ) ;
232238 } ) ;
233239
@@ -240,6 +246,10 @@ describe('SimpleEventPlugin', function () {
240246 ReactDOMClient = require ( 'react-dom/client' ) ;
241247 Scheduler = require ( 'scheduler' ) ;
242248
249+ const InternalTestUtils = require ( 'internal-test-utils' ) ;
250+ assertLog = InternalTestUtils . assertLog ;
251+ waitForAll = InternalTestUtils . waitForAll ;
252+
243253 act = require ( 'jest-react' ) . act ;
244254 } ) ;
245255
@@ -274,10 +284,10 @@ describe('SimpleEventPlugin', function () {
274284 // Initial mount
275285 root . render ( < Button /> ) ;
276286 // Should not have flushed yet because it's async
277- expect ( Scheduler ) . toHaveYielded ( [ ] ) ;
287+ assertLog ( [ ] ) ;
278288 expect ( button ) . toBe ( undefined ) ;
279289 // Flush async work
280- expect ( Scheduler ) . toFlushAndYield ( [ 'render button: enabled' ] ) ;
290+ await waitForAll ( [ 'render button: enabled' ] ) ;
281291
282292 function click ( ) {
283293 const event = new MouseEvent ( 'click' , {
@@ -292,7 +302,7 @@ describe('SimpleEventPlugin', function () {
292302
293303 // Click the button to trigger the side-effect
294304 await act ( async ( ) => click ( ) ) ;
295- expect ( Scheduler ) . toHaveYielded ( [
305+ assertLog ( [
296306 // The handler fired
297307 'Side-effect' ,
298308 // The component re-rendered synchronously, even in concurrent mode.
@@ -301,7 +311,7 @@ describe('SimpleEventPlugin', function () {
301311
302312 // Click the button again
303313 click ( ) ;
304- expect ( Scheduler ) . toHaveYielded ( [
314+ assertLog ( [
305315 // The event handler was removed from the button, so there's no effect.
306316 ] ) ;
307317
@@ -312,7 +322,7 @@ describe('SimpleEventPlugin', function () {
312322 click ( ) ;
313323 click ( ) ;
314324 click ( ) ;
315- expect ( Scheduler ) . toFlushAndYield ( [ ] ) ;
325+ await waitForAll ( [ ] ) ;
316326 } ) ;
317327
318328 // NOTE: This test was written for the old behavior of discrete updates,
@@ -345,7 +355,7 @@ describe('SimpleEventPlugin', function () {
345355 // Should not have flushed yet because it's async
346356 expect ( button ) . toBe ( undefined ) ;
347357 // Flush async work
348- Scheduler . unstable_flushAll ( ) ;
358+ await waitForAll ( [ ] ) ;
349359 expect ( button . textContent ) . toEqual ( 'Count: 0' ) ;
350360
351361 function click ( ) {
@@ -373,7 +383,7 @@ describe('SimpleEventPlugin', function () {
373383 await act ( async ( ) => click ( ) ) ;
374384
375385 // Flush the remaining work
376- Scheduler . unstable_flushAll ( ) ;
386+ await waitForAll ( [ ] ) ;
377387 // The counter should equal the total number of clicks
378388 expect ( button . textContent ) . toEqual ( 'Count: 7' ) ;
379389 } ) ;
0 commit comments