import React from 'react';
import { render, mount } from 'enzyme';
import Drawer from '..';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
const DrawerTest = ({ getContainer }) => (
Here is content of Drawer
);
describe('Drawer', () => {
mountTest(Drawer);
rtlTest(Drawer);
it('render correctly', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('getContainer return undefined', () => {
let wrapper = mount( undefined} />);
expect(wrapper.render()).toMatchSnapshot();
wrapper = mount();
expect(wrapper.render()).toMatchSnapshot();
});
it('render top drawer', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('have a title', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('closable is false', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('destroyOnClose is true', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('className is test_drawer', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('style/drawerStyle/headerStyle/bodyStyle should work', () => {
const style = {
backgroundColor: '#08c',
};
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('have a footer', () => {
const wrapper = render(
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('forceRender works', () => {
const wrapper = mount(
,
);
expect(wrapper.find('button.forceRender').length).toBe(0);
const wrapper2 = mount(
,
);
expect(wrapper2.find('button.forceRender').length).toBe(1);
});
it('support closeIcon', () => {
const wrapper = render(
close} width={400} getContainer={false}>
Here is content of Drawer
,
);
expect(wrapper).toMatchSnapshot();
});
it('ConfigProvider should not warning', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount(
Bamboo is Light,
);
expect(errorSpy).not.toHaveBeenCalled();
errorSpy.mockRestore();
});
it('should support ref', () => {
const ref = React.createRef();
mount(
Here is content of Drawer
,
);
expect(typeof ref.current.push).toBe('function');
expect(typeof ref.current.pull).toBe('function');
});
});