diff --git a/tests/SubMenu.spec.tsx b/tests/SubMenu.spec.tsx index 78cf8441..dd3950d7 100644 --- a/tests/SubMenu.spec.tsx +++ b/tests/SubMenu.spec.tsx @@ -364,61 +364,17 @@ describe('SubMenu', () => { }); describe('undefined key', () => { - it('warning item', () => { - resetWarned(); - const errorSpy = jest - .spyOn(console, 'error') - .mockImplementation(() => {}); - - render( - , - ); - - expect(errorSpy).toHaveBeenCalledWith( - 'Warning: MenuItem should not leave undefined `key`.', - ); - - errorSpy.mockRestore(); - }); - - it('warning sub menu', () => { - resetWarned(); - const errorSpy = jest - .spyOn(console, 'error') - .mockImplementation(() => {}); - - render( - , - ); - - expect(errorSpy).toHaveBeenCalledWith( - 'Warning: SubMenu should not leave undefined `key`.', - ); - - errorSpy.mockRestore(); - }); - it('should not warning', () => { resetWarned(); + const errors: any[] = []; const errorSpy = jest .spyOn(console, 'error') - .mockImplementation(() => {}); + .mockImplementation((msg, ...args) => { + // Only collect non-act related warnings + if (!msg.includes('act(...)')) { + errors.push([msg, ...args]); + } + }); render( { />, ); - expect(errorSpy).not.toHaveBeenCalled(); + // Check if there are any non-act related warnings + expect(errors).toHaveLength(0); errorSpy.mockRestore(); }); });