mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 11:32:52 +08:00
test: console.error
should nullable in Console (#39050)
This commit is contained in:
parent
94049f1406
commit
4efa3b2896
@ -2,7 +2,7 @@ describe('Test warning', () => {
|
|||||||
let spy: jest.SpyInstance;
|
let spy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
spy = jest.spyOn(console, 'error');
|
spy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
@ -76,9 +76,8 @@ describe('Alert', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show error as ErrorBoundary when children have error', () => {
|
it('should show error as ErrorBoundary when children have error', () => {
|
||||||
jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
// eslint-disable-next-line no-console
|
expect(warnSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(console.error).toHaveBeenCalledTimes(0);
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
// eslint-disable-next-line react/jsx-no-undef
|
// eslint-disable-next-line react/jsx-no-undef
|
||||||
const ThrowError = () => <NotExisted />;
|
const ThrowError = () => <NotExisted />;
|
||||||
@ -91,8 +90,7 @@ describe('Alert', () => {
|
|||||||
expect(screen.getByRole('alert')).toHaveTextContent(
|
expect(screen.getByRole('alert')).toHaveTextContent(
|
||||||
'ReferenceError: NotExisted is not defined',
|
'ReferenceError: NotExisted is not defined',
|
||||||
);
|
);
|
||||||
// eslint-disable-next-line no-console
|
warnSpy.mockRestore();
|
||||||
(console.error as any).mockRestore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('could be used with Tooltip', async () => {
|
it('could be used with Tooltip', async () => {
|
||||||
|
@ -49,7 +49,7 @@ describe('AutoComplete', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('AutoComplete throws error when contains invalid dataSource', () => {
|
it('AutoComplete throws error when contains invalid dataSource', () => {
|
||||||
const spy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
|
||||||
render(
|
render(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@ -82,13 +82,10 @@ describe('AutoComplete', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not warning when getInputElement is null', () => {
|
it('should not warning when getInputElement is null', () => {
|
||||||
jest.spyOn(console, 'warn').mockImplementation(() => undefined);
|
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||||
render(<AutoComplete placeholder="input here" allowClear />);
|
render(<AutoComplete placeholder="input here" allowClear />);
|
||||||
// eslint-disable-next-line no-console
|
expect(warnSpy).not.toHaveBeenCalled();
|
||||||
expect(console.warn).not.toHaveBeenCalled();
|
warnSpy.mockRestore();
|
||||||
// @ts-ignore
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.warn.mockRestore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not override custom input className', () => {
|
it('should not override custom input className', () => {
|
||||||
|
@ -8,7 +8,7 @@ const { QuarterPicker } = DatePicker;
|
|||||||
describe('QuarterPicker', () => {
|
describe('QuarterPicker', () => {
|
||||||
it('should support style prop', () => {
|
it('should support style prop', () => {
|
||||||
resetWarned();
|
resetWarned();
|
||||||
const warnSpy = jest.spyOn(console, 'error');
|
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
|
||||||
const { container } = render(<QuarterPicker style={{ width: 400 }} />);
|
const { container } = render(<QuarterPicker style={{ width: 400 }} />);
|
||||||
expect(container.firstChild).toMatchSnapshot();
|
expect(container.firstChild).toMatchSnapshot();
|
||||||
|
@ -116,7 +116,7 @@ describe('Dropdown', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should warn if use topCenter or bottomCenter', () => {
|
it('should warn if use topCenter or bottomCenter', () => {
|
||||||
const error = jest.spyOn(console, 'error');
|
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
render(
|
render(
|
||||||
<div>
|
<div>
|
||||||
<Dropdown menu={{ items }} placement="bottomCenter">
|
<Dropdown menu={{ items }} placement="bottomCenter">
|
||||||
|
@ -1040,7 +1040,7 @@ describe('Menu', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not warning deprecated message when items={undefined}', () => {
|
it('should not warning deprecated message when items={undefined}', () => {
|
||||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
render(<Menu items={undefined} />);
|
render(<Menu items={undefined} />);
|
||||||
expect(errorSpy).not.toHaveBeenCalledWith(
|
expect(errorSpy).not.toHaveBeenCalledWith(
|
||||||
expect.stringContaining('`children` will be removed in next major version'),
|
expect.stringContaining('`children` will be removed in next major version'),
|
||||||
|
@ -41,7 +41,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
|
|||||||
// });
|
// });
|
||||||
// jest.spyOn(window, 'cancelAnimationFrame').mockImplementation(id => window.clearTimeout(id));
|
// jest.spyOn(window, 'cancelAnimationFrame').mockImplementation(id => window.clearTimeout(id));
|
||||||
|
|
||||||
const errorSpy = jest.spyOn(console, 'error');
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
// Hack error to remove act warning
|
// Hack error to remove act warning
|
||||||
|
@ -181,7 +181,7 @@ describe('Space', () => {
|
|||||||
|
|
||||||
// https://github.com/ant-design/ant-design/issues/35305
|
// https://github.com/ant-design/ant-design/issues/35305
|
||||||
it('should not throw duplicated key warning', () => {
|
it('should not throw duplicated key warning', () => {
|
||||||
jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
render(
|
render(
|
||||||
<Space>
|
<Space>
|
||||||
<div key="1" />
|
<div key="1" />
|
||||||
@ -190,11 +190,11 @@ describe('Space', () => {
|
|||||||
<div />
|
<div />
|
||||||
</Space>,
|
</Space>,
|
||||||
);
|
);
|
||||||
expect(console.error).not.toHaveBeenCalledWith(
|
expect(spy).not.toHaveBeenCalledWith(
|
||||||
expect.stringContaining('Encountered two children with the same key'),
|
expect.stringContaining('Encountered two children with the same key'),
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
);
|
);
|
||||||
(console.error as any).mockRestore();
|
spy.mockRestore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -117,7 +117,7 @@ describe('Table.filter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('renders empty menu correctly', () => {
|
it('renders empty menu correctly', () => {
|
||||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
const { container } = render(
|
const { container } = render(
|
||||||
createTable({
|
createTable({
|
||||||
columns: [
|
columns: [
|
||||||
|
Loading…
Reference in New Issue
Block a user