ant-design/components/modal/__tests__/Modal.test.js
Wei Zhu 55c85f77a1
Update dependendies (#8150)
* deps: upgrade rc-menu, and close: #2837

* test: update snapshots

* Update rc-calendar

* Update rc-cascader

* Update rc-dialog

* Update dropdown

* Update rc-select@7.1.0

* Update rc-slider

* Update rc-time-picker

* Update rc-tooltip

* Update rc-tree-select

* Mock rc-trigger and Portal

* Fix animation warning when inlineCollapsed changes

* fix: should use SubMenu[popupClassName]

* Fix typescript error

* Fix lint

* fix: style for menu

* Mock rc-trigger for React 15

* Remvoe allow_failures
2017-11-11 00:07:03 +08:00

48 lines
1.1 KiB
JavaScript

import React from 'react';
import { mount } from 'enzyme';
import Modal from '..';
jest.mock('rc-util/lib/Portal');
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 (
<div>
<div ref={this.saveContainer} />
<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 />);
expect(wrapper.render()).toMatchSnapshot();
});
it('render without footer', () => {
const wrapper = mount(<ModalTester footer={null} />);
expect(wrapper.render()).toMatchSnapshot();
});
});