import { mount } from 'enzyme';
import React from 'react';
import ProCard from '@ant-design/pro-card';
import { waitForComponentToPaint } from '../util';
import { act } from 'react-dom/test-utils';
import { Grid } from 'antd';
jest.mock('antd/lib/grid/hooks/useBreakpoint');
describe('Card', () => {
it('🥩 collapsible onCollapse', async () => {
const fn = jest.fn();
const wrapper = mount(
内容
,
);
await waitForComponentToPaint(wrapper);
act(() => {
wrapper.find('AntdIcon.ant-pro-card-collapsible-icon').simulate('click');
});
expect(fn).toBeCalled();
});
it('🥩 resize breakpoint', async () => {
// @ts-ignore
Grid.useBreakpoint.mockReturnValue({ xs: true });
const wrapper = mount(
Col
,
);
await waitForComponentToPaint(wrapper);
});
it('🥩 collapsible defaultCollapsed', async () => {
const wrapper = mount(
内容
,
);
await waitForComponentToPaint(wrapper);
expect(wrapper.find('.ant-pro-card-collapse').exists()).toBeTruthy();
});
it('🥩 collapsible collapsed', async () => {
const wrapper = mount(
内容
,
);
await waitForComponentToPaint(wrapper);
expect(wrapper.find('.ant-pro-card-collapse').exists()).toBeTruthy();
wrapper.setProps({
collapsed: false,
});
await waitForComponentToPaint(wrapper);
expect(wrapper.find('.ant-pro-card-collapse').exists()).toBeFalsy();
});
it('🥩 tabs onChange', async () => {
const fn = jest.fn();
const wrapper = mount(
内容一
内容二
,
);
act(() => {
wrapper.find('.ant-pro-card-tabs .ant-tabs-tab').at(1).simulate('click');
});
expect(fn).toHaveBeenCalledWith('tab2');
});
});