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';
|
|
|
|
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;
|
|
|
|
|
|
|
|
const wrapper = mount(<Demo />, { hydrateIn: div });
|
|
|
|
|
|
|
|
expect(warnSpy).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
warnSpy.mockRestore();
|
|
|
|
|
|
|
|
wrapper.unmount();
|
|
|
|
});
|
2021-02-01 10:15:39 +08:00
|
|
|
});
|