2017-03-30 16:06:03 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import Modal from '..';
|
|
|
|
|
2017-11-11 00:07:03 +08:00
|
|
|
jest.mock('rc-util/lib/Portal');
|
|
|
|
|
2017-03-30 16:06:03 +08:00
|
|
|
class ModalTester extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = { visible: false };
|
|
|
|
}
|
|
|
|
componentDidMount() {
|
|
|
|
this.setState({ visible: true }); // eslint-disable-line react/no-did-mount-set-state
|
|
|
|
}
|
|
|
|
saveContainer = (container) => {
|
|
|
|
this.container = container;
|
|
|
|
}
|
|
|
|
getContainer = () => {
|
|
|
|
return this.container;
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
return (
|
2017-04-05 16:21:21 +08:00
|
|
|
<div>
|
|
|
|
<div ref={this.saveContainer} />
|
2017-03-30 16:06:03 +08:00
|
|
|
<Modal
|
|
|
|
{...this.props}
|
|
|
|
visible={this.state.visible}
|
|
|
|
getContainer={this.getContainer}
|
|
|
|
>
|
|
|
|
Here is content of Modal
|
|
|
|
</Modal>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Modal', () => {
|
|
|
|
it('render correctly', () => {
|
|
|
|
const wrapper = mount(<ModalTester />);
|
2017-04-02 18:09:23 +08:00
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
2017-03-30 16:06:03 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render without footer', () => {
|
|
|
|
const wrapper = mount(<ModalTester footer={null} />);
|
2017-04-02 18:09:23 +08:00
|
|
|
expect(wrapper.render()).toMatchSnapshot();
|
2017-03-30 16:06:03 +08:00
|
|
|
});
|
|
|
|
});
|