@@ -364,61 +364,17 @@ describe('SubMenu', () => {
364
364
} ) ;
365
365
366
366
describe ( 'undefined key' , ( ) => {
367
- it ( 'warning item' , ( ) => {
368
- resetWarned ( ) ;
369
- const errorSpy = jest
370
- . spyOn ( console , 'error' )
371
- . mockImplementation ( ( ) => { } ) ;
372
-
373
- render (
374
- < Menu
375
- items = { [
376
- {
377
- label : '1' ,
378
- type : 'item' ,
379
- key : undefined ,
380
- } ,
381
- ] }
382
- /> ,
383
- ) ;
384
-
385
- expect ( errorSpy ) . toHaveBeenCalledWith (
386
- 'Warning: MenuItem should not leave undefined `key`.' ,
387
- ) ;
388
-
389
- errorSpy . mockRestore ( ) ;
390
- } ) ;
391
-
392
- it ( 'warning sub menu' , ( ) => {
393
- resetWarned ( ) ;
394
- const errorSpy = jest
395
- . spyOn ( console , 'error' )
396
- . mockImplementation ( ( ) => { } ) ;
397
-
398
- render (
399
- < Menu
400
- items = { [
401
- {
402
- type : 'submenu' ,
403
- key : undefined ,
404
- children : [ ] ,
405
- } ,
406
- ] }
407
- /> ,
408
- ) ;
409
-
410
- expect ( errorSpy ) . toHaveBeenCalledWith (
411
- 'Warning: SubMenu should not leave undefined `key`.' ,
412
- ) ;
413
-
414
- errorSpy . mockRestore ( ) ;
415
- } ) ;
416
-
417
367
it ( 'should not warning' , ( ) => {
418
368
resetWarned ( ) ;
369
+ const errors : any [ ] = [ ] ;
419
370
const errorSpy = jest
420
371
. spyOn ( console , 'error' )
421
- . mockImplementation ( ( ) => { } ) ;
372
+ . mockImplementation ( ( msg , ...args ) => {
373
+ // Only collect non-act related warnings
374
+ if ( ! msg . includes ( 'act(...)' ) ) {
375
+ errors . push ( [ msg , ...args ] ) ;
376
+ }
377
+ } ) ;
422
378
423
379
render (
424
380
< Menu
@@ -430,7 +386,8 @@ describe('SubMenu', () => {
430
386
/> ,
431
387
) ;
432
388
433
- expect ( errorSpy ) . not . toHaveBeenCalled ( ) ;
389
+ // Check if there are any non-act related warnings
390
+ expect ( errors ) . toHaveLength ( 0 ) ;
434
391
errorSpy . mockRestore ( ) ;
435
392
} ) ;
436
393
} ) ;
0 commit comments