afc163
8 years ago
5 changed files with 157 additions and 163 deletions
@ -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(); |
|||
}); |
|||
}); |
@ -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> |
|||
`; |
@ -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> |
|||
`; |
@ -1,3 +0,0 @@ |
|||
import demoTest from '../../../tests/shared/demoTest'; |
|||
|
|||
demoTest('modal'); |
Loading…
Reference in new issue