mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 01:11:26 +08:00
d07dcd46b7
* fix: wipe out unnecessary prop * wipe out unnecessary prop(`row-gap: 0px`) on <Row /> * add test case * chore: remove unnecessary import * chore: add prop to Row and Col * chore: update snapshot (Form/Grid/Card) * chore: update snapshot * chore: move location
65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
import ReactDOMServer from 'react-dom/server';
|
|
import { mount } from 'enzyme';
|
|
import { render, screen } from '../../../tests/utils';
|
|
import { Col, Row } from '..';
|
|
// eslint-disable-next-line no-unused-vars
|
|
import * as styleChecker from '../../_util/styleChecker';
|
|
|
|
jest.mock('../../_util/styleChecker', () => ({
|
|
canUseDocElement: () => true,
|
|
isStyleSupport: () => true,
|
|
detectFlexGapSupported: () => true,
|
|
}));
|
|
|
|
describe('Grid.Gap', () => {
|
|
it('should not have `row-gap: 0px` style', () => {
|
|
render(
|
|
<Row>
|
|
<Col />
|
|
</Row>,
|
|
);
|
|
|
|
expect(screen.getByRole('row').style.rowGap).toBe('');
|
|
});
|
|
|
|
it('should use gap', () => {
|
|
const wrapper = mount(
|
|
<Row gutter={[16, 8]}>
|
|
<Col />
|
|
</Row>,
|
|
);
|
|
|
|
expect(wrapper.find('.ant-row').props().style).toEqual(
|
|
expect.objectContaining({
|
|
marginLeft: -8,
|
|
rowGap: 8,
|
|
marginRight: -8,
|
|
}),
|
|
);
|
|
});
|
|
|
|
it('not break ssr', () => {
|
|
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
const Demo = () => (
|
|
<Row gutter={[16, 8]}>
|
|
<Col />
|
|
</Row>
|
|
);
|
|
|
|
const div = document.createElement('div');
|
|
|
|
const ssrTxt = ReactDOMServer.renderToString(<Demo />);
|
|
div.innerHTML = ssrTxt;
|
|
|
|
const { unmount } = render(<Demo />, { container: div, hydrate: true });
|
|
|
|
expect(warnSpy).not.toHaveBeenCalled();
|
|
|
|
warnSpy.mockRestore();
|
|
|
|
unmount();
|
|
});
|
|
});
|