2018-06-19 16:47:52 +08:00
|
|
|
import React from 'react';
|
2018-07-20 14:40:03 +08:00
|
|
|
import { render } from 'enzyme';
|
2018-06-19 16:47:52 +08:00
|
|
|
import Drawer from '..';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2020-01-02 19:10:16 +08:00
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
2018-06-19 16:47:52 +08:00
|
|
|
|
|
|
|
describe('Drawer', () => {
|
2019-08-26 22:53:20 +08:00
|
|
|
mountTest(Drawer);
|
2020-01-02 19:10:16 +08:00
|
|
|
rtlTest(Drawer);
|
2019-08-26 22:53:20 +08:00
|
|
|
|
2018-07-20 14:40:03 +08:00
|
|
|
it('render correctly', () => {
|
|
|
|
const wrapper = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Drawer visible width={400} getContainer={false}>
|
2018-07-20 14:40:03 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-20 14:40:03 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-08-10 13:32:33 +08:00
|
|
|
it('render top drawer', () => {
|
|
|
|
const wrapper = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Drawer visible height={400} placement="top" getContainer={false}>
|
2018-08-10 13:32:33 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-08-10 13:32:33 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-07-20 14:40:03 +08:00
|
|
|
it('have a title', () => {
|
|
|
|
const wrapper = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Drawer visible title="Test Title" getContainer={false}>
|
2018-07-20 14:40:03 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-20 14:40:03 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('closable is false', () => {
|
|
|
|
const wrapper = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Drawer visible closable={false} getContainer={false}>
|
2018-07-20 14:40:03 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-20 14:40:03 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-06-21 12:32:13 +08:00
|
|
|
it('destroyOnClose is true', () => {
|
2018-07-20 14:40:03 +08:00
|
|
|
const wrapper = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Drawer destroyOnClose visible={false} getContainer={false}>
|
2018-06-26 11:19:49 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-06-26 11:19:49 +08:00
|
|
|
);
|
2018-07-20 14:40:03 +08:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
2018-06-19 16:47:52 +08:00
|
|
|
});
|
2018-07-22 11:27:48 +08:00
|
|
|
|
2018-08-05 14:16:08 +08:00
|
|
|
it('className is test_drawer', () => {
|
2018-07-22 11:27:48 +08:00
|
|
|
const wrapper = render(
|
2018-12-07 16:17:45 +08:00
|
|
|
<Drawer destroyOnClose visible={false} className="test_drawer" getContainer={false}>
|
2018-07-22 11:27:48 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-22 11:27:48 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2019-10-07 18:58:10 +08:00
|
|
|
|
|
|
|
it('style/drawerStyle/headerStyle/bodyStyle should work', () => {
|
|
|
|
const style = {
|
|
|
|
backgroundColor: '#08c',
|
|
|
|
};
|
|
|
|
const wrapper = render(
|
|
|
|
<Drawer
|
|
|
|
visible
|
|
|
|
style={style}
|
|
|
|
drawerStyle={style}
|
|
|
|
headerStyle={style}
|
|
|
|
bodyStyle={style}
|
|
|
|
getContainer={false}
|
|
|
|
>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-06-19 16:47:52 +08:00
|
|
|
});
|