ant-design/components/layout/__tests__/warning.test.tsx
二货爱吃白萝卜 94bf744acd
fix: Layout throw warning of suffixCls (#40969)
* fix: Layout throw warning of suffixCls

* chore: fix lint
2023-02-28 16:26:21 +08:00

32 lines
1.1 KiB
TypeScript

import React from 'react';
import Layout from '..';
import { render } from '../../../tests/utils';
const { Sider, Footer, Header } = Layout;
describe('Layout.Warning', () => {
(['Layout', 'Header', 'Footer', 'Sider'] as const).forEach((tag) => {
const ComponentMap = { Layout, Header, Footer, Sider };
// Since react will not throw warning for same message.
// We create a new test suite here
it(`not warning of non-element attr on ${tag}`, () => {
/**
* Should not call:
* Warning: React does not recognize the `suffixCls` prop on a DOM element.
* If you intentionally want it to appear in the DOM as a custom attribute,
* spell it as lowercase `suffixcls` instead.
* If you accidentally passed it from a parent component,
* remove it from the DOM element.
*/
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const Component = ComponentMap[tag];
render(<Component>{tag}</Component>);
expect(errorSpy).not.toHaveBeenCalled();
errorSpy.mockRestore();
});
});
});