ant-design-vue/components/modal/__tests__/Modal.test.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import Modal from '..';
const ModalTester = {
props: ['footer', 'visible'],
methods: {
2019-01-12 03:33:27 +00:00
getContainer() {
return this.$refs.container;
},
},
2019-01-12 03:33:27 +00:00
render() {
const modalProps = {
props: {
...this.$props,
getContainer: this.getContainer,
},
2019-01-12 03:33:27 +00:00
};
return (
<div>
2019-01-12 03:33:27 +00:00
<div ref="container" />
<Modal {...modalProps}>Here is content of Modal</Modal>
</div>
2019-01-12 03:33:27 +00:00
);
},
2019-01-12 03:33:27 +00:00
};
describe('Modal', () => {
2019-01-12 03:33:27 +00:00
it('render correctly', done => {
const wrapper = mount({
render() {
return <ModalTester visible />;
},
});
expect(wrapper.html()).toMatchSnapshot();
2018-05-18 06:30:17 +00:00
// https://github.com/vuejs/vue-test-utils/issues/624
const wrapper1 = mount(ModalTester, {
sync: false,
2019-01-12 03:33:27 +00:00
});
wrapper1.setProps({ visible: true });
2018-05-18 06:30:17 +00:00
Vue.nextTick(() => {
2019-01-12 03:33:27 +00:00
expect(wrapper1.html()).toMatchSnapshot();
done();
});
});
it('render without footer', () => {
2019-01-12 03:33:27 +00:00
const wrapper = mount({
render() {
return <ModalTester visible footer={null} />;
},
});
expect(wrapper.html()).toMatchSnapshot();
});
});