Browse Source

Merge branch 'master' into feature-2.9

pull/5558/head
afc163 8 years ago
parent
commit
e030d10e99
  1. 45
      components/modal/__tests__/Modal.test.js
  2. 111
      components/modal/__tests__/__snapshots__/Modal.test.js.snap
  3. 159
      components/modal/__tests__/__snapshots__/demo.test.js.snap
  4. 3
      components/modal/__tests__/demo.test.js
  5. 2
      package.json

45
components/modal/__tests__/Modal.test.js

@ -0,0 +1,45 @@
import React from 'react';
import { mount } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import Modal from '..';
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 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(renderToJson(wrapper.render())).toMatchSnapshot();
});
it('render without footer', () => {
const wrapper = mount(<ModalTester footer={null} />);
expect(renderToJson(wrapper.render())).toMatchSnapshot();
});
});

111
components/modal/__tests__/__snapshots__/Modal.test.js.snap

@ -0,0 +1,111 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Modal render correctly 1`] = `
<div>
<div>
<div
class="ant-modal-mask fade-appear"
/>
<div
class="ant-modal-wrap "
role="dialog"
tabindex="-1"
>
<div
class="ant-modal zoom-appear"
role="document"
style="width: 520px;"
>
<div
class="ant-modal-content"
>
<button
aria-label="Close"
class="ant-modal-close"
>
<span
class="ant-modal-close-x"
/>
</button>
<div
class="ant-modal-body"
>
Here is content of Modal
</div>
<div
class="ant-modal-footer"
>
<button
class="ant-btn ant-btn-lg"
type="button"
>
<span>
取 消
</span>
</button>
<button
class="ant-btn ant-btn-primary ant-btn-lg"
type="button"
>
<span>
确 定
</span>
</button>
</div>
</div>
<div
style="width: 0px; height: 0px; overflow: hidden;"
tabindex="0"
>
sentinel
</div>
</div>
</div>
</div>
</div>
`;
exports[`Modal render without footer 1`] = `
<div>
<div>
<div
class="ant-modal-mask fade-appear"
/>
<div
class="ant-modal-wrap "
role="dialog"
tabindex="-1"
>
<div
class="ant-modal zoom-appear"
role="document"
style="width: 520px;"
>
<div
class="ant-modal-content"
>
<button
aria-label="Close"
class="ant-modal-close"
>
<span
class="ant-modal-close-x"
/>
</button>
<div
class="ant-modal-body"
>
Here is content of Modal
</div>
</div>
<div
style="width: 0px; height: 0px; overflow: hidden;"
tabindex="0"
>
sentinel
</div>
</div>
</div>
</div>
</div>
`;

159
components/modal/__tests__/__snapshots__/demo.test.js.snap

@ -1,159 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders ./components/modal/demo/async.md correctly 1`] = `
<div>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open a modal dialog
</span>
</button>
</div>
`;
exports[`renders ./components/modal/demo/basic.md correctly 1`] = `
<div>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open a modal dialog
</span>
</button>
</div>
`;
exports[`renders ./components/modal/demo/confirm.md correctly 1`] = `
<button
class="ant-btn"
type="button"
>
<span>
confirmation modal dialog
</span>
</button>
`;
exports[`renders ./components/modal/demo/confirm-promise.md correctly 1`] = `
<button
class="ant-btn"
type="button"
>
<span>
Confirmation modal dialog
</span>
</button>
`;
exports[`renders ./components/modal/demo/footer.md correctly 1`] = `
<div>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Open modal dialog
</span>
</button>
</div>
`;
exports[`renders ./components/modal/demo/info.md correctly 1`] = `
<div>
<button
class="ant-btn"
type="button"
>
<span>
Info
</span>
</button>
<button
class="ant-btn"
type="button"
>
<span>
Success
</span>
</button>
<button
class="ant-btn"
type="button"
>
<span>
Error
</span>
</button>
<button
class="ant-btn"
type="button"
>
<span>
Warning
</span>
</button>
</div>
`;
exports[`renders ./components/modal/demo/locale.md correctly 1`] = `
<div>
<div>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Show Modal
</span>
</button>
</div>
<br />
<button
class="ant-btn"
type="button"
>
<span>
confirm
</span>
</button>
</div>
`;
exports[`renders ./components/modal/demo/manual.md correctly 1`] = `
<div>
<button
class="ant-btn"
type="button"
>
<span>
Success
</span>
</button>
</div>
`;
exports[`renders ./components/modal/demo/position.md correctly 1`] = `
<div>
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Display a modal dialog at 20px to Top
</span>
</button>
<br />
<br />
<button
class="ant-btn ant-btn-primary"
type="button"
>
<span>
Vertically centered modal dialog
</span>
</button>
</div>
`;

3
components/modal/__tests__/demo.test.js

@ -1,3 +0,0 @@
import demoTest from '../../../tests/shared/demoTest';
demoTest('modal');

2
package.json

@ -59,7 +59,7 @@
"rc-radio": "~2.0.0",
"rc-rate": "~2.1.0",
"rc-select": "~6.8.0",
"rc-slider": "~6.1.0",
"rc-slider": "~6.3.0",
"rc-steps": "~2.4.0",
"rc-switch": "~1.4.2",
"rc-table": "~5.2.13",

Loading…
Cancel
Save