test: add mockRestore to fix incorrect test case (#38454)

This commit is contained in:
lijianan 2022-11-09 11:55:11 +08:00 committed by GitHub
parent fe9ac7b936
commit b36f013e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,16 +131,18 @@ describe('DropdownButton', () => {
'ant-btn',
);
});
it('should throw Error then `overlay` in props', () => {
it('should console Error then `overlay` in props', () => {
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<DropdownButton overlay={<div>test</div>} />);
expect(errSpy).toHaveBeenCalledWith(
'Warning: [antd: Dropdown] `overlay` is deprecated. Please use `menu` instead.',
);
errSpy.mockRestore();
});
it('should not throw Error then `overlay` not in props', () => {
it('should not console Error then `overlay` not in props', () => {
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(<DropdownButton />);
expect(errSpy).toHaveBeenCalled();
expect(errSpy).not.toHaveBeenCalled();
errSpy.mockRestore();
});
});