2018-06-19 16:47:52 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Drawer from '..';
|
|
|
|
|
|
|
|
|
|
|
|
class DrawerTester extends React.Component {
|
|
|
|
saveContainer = (container) => {
|
|
|
|
this.container = container;
|
|
|
|
}
|
2018-06-26 00:22:50 +08:00
|
|
|
|
2018-06-19 16:47:52 +08:00
|
|
|
getContainer = () => {
|
2018-06-19 17:42:25 +08:00
|
|
|
return this.container;
|
2018-06-19 16:47:52 +08:00
|
|
|
}
|
2018-06-26 00:22:50 +08:00
|
|
|
|
2018-06-19 16:47:52 +08:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
2018-06-19 17:42:25 +08:00
|
|
|
<div ref={this.saveContainer} />
|
2018-06-19 16:47:52 +08:00
|
|
|
<Drawer
|
2018-06-25 20:25:15 +08:00
|
|
|
visible
|
2018-06-19 16:47:52 +08:00
|
|
|
getContainer={this.getContainer}
|
2018-06-21 12:32:13 +08:00
|
|
|
{...this.props}
|
2018-06-19 16:47:52 +08:00
|
|
|
>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Drawer', () => {
|
2018-06-25 20:25:15 +08:00
|
|
|
it('render correctly', () => {
|
2018-06-21 13:52:09 +08:00
|
|
|
const wrapper = mount(<DrawerTester width={400} />);
|
2018-06-21 12:32:13 +08:00
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('have a title', () => {
|
|
|
|
const wrapper = mount(<DrawerTester title="Test Title" />);
|
2018-06-25 23:25:38 +08:00
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
2018-06-21 12:32:13 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('closable is false', () => {
|
|
|
|
const wrapper = mount(<DrawerTester closable={false} />);
|
2018-06-25 23:25:38 +08:00
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
2018-06-21 12:32:13 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('destroyOnClose is true', () => {
|
|
|
|
const wrapper = mount(<DrawerTester destroyOnClose visible={false} />);
|
2018-06-25 23:25:38 +08:00
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
2018-06-19 16:47:52 +08:00
|
|
|
});
|
|
|
|
});
|