Skip to content

Commit

Permalink
test: add mockRestore to fix incorrect test case (ant-design#38454)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan authored and elevensky committed Nov 22, 2022
1 parent 6a6b089 commit 3cedeef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/dropdown/__tests__/dropdown-button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

0 comments on commit 3cedeef

Please sign in to comment.