ant-design/components/grid/__tests__/gap.test.js
afc163 30ac6bd4e4
test: wrap React.StrictMode for test cases (#35026)
* test: React StrictMode

* test: fix Spin test

* chore: wrapper enzyme

* test: fix setState

* test: more test cover

* test: more test cover

* test: more test cover

* test: more test cover

* test: more test cover

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: more test case

* test: disable part of it

* test: fix test & add placeholder

* test: Use orign enzyme mount

Co-authored-by: zombiej <smith3816@gmail.com>
2022-04-18 21:02:11 +08:00

55 lines
1.3 KiB
JavaScript

import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { mount } from 'enzyme';
import { render } 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 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();
});
});