ant-design/components/layout/__tests__/warning.test.tsx
叶枫 502dac12aa
docs: format code (#48309)
* docs: fix code

* feat: lint

* feat: prettier

* feat: test

* feat: review

* feat: format html

* feat: format html
2024-04-08 14:04:08 +08:00

33 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();
});
});
});