2021-02-01 10:15:39 +08:00
|
|
|
import React from 'react';
|
2021-03-02 20:29:00 +08:00
|
|
|
import ReactDOMServer from 'react-dom/server';
|
2021-02-01 10:15:39 +08:00
|
|
|
import { mount } from 'enzyme';
|
2022-04-18 21:02:11 +08:00
|
|
|
import { render } from '../../../tests/utils';
|
2021-02-01 10:15:39 +08:00
|
|
|
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,
|
2021-02-03 15:39:51 +08:00
|
|
|
detectFlexGapSupported: () => true,
|
2021-02-01 10:15:39 +08:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('Grid.Gap', () => {
|
|
|
|
it('should use gap', () => {
|
|
|
|
const wrapper = mount(
|
|
|
|
<Row gutter={[16, 8]}>
|
|
|
|
<Col />
|
|
|
|
</Row>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(wrapper.find('.ant-row').props().style).toEqual(
|
|
|
|
expect.objectContaining({
|
2021-02-03 18:06:51 +08:00
|
|
|
marginLeft: -8,
|
|
|
|
rowGap: 8,
|
|
|
|
marginRight: -8,
|
2021-02-01 10:15:39 +08:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
2021-03-02 20:29:00 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-04-06 11:07:15 +08:00
|
|
|
const { unmount } = render(<Demo />, { container: div, hydrate: true });
|
2021-03-02 20:29:00 +08:00
|
|
|
|
|
|
|
expect(warnSpy).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
warnSpy.mockRestore();
|
|
|
|
|
2022-04-06 11:07:15 +08:00
|
|
|
unmount();
|
2021-03-02 20:29:00 +08:00
|
|
|
});
|
2021-02-01 10:15:39 +08:00
|
|
|
});
|