2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { asyncExpect } from '@/tests/utils';
|
|
|
|
import Drawer from '..';
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
const DrawerCom = {
|
|
|
|
props: {
|
|
|
|
visible: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
destroyOnClose: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
getContainer: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
wrapClassName: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2018-09-05 13:28:54 +00:00
|
|
|
const drawerProps = {
|
|
|
|
props: {
|
|
|
|
destroyOnClose: true,
|
|
|
|
getContainer: false,
|
|
|
|
visible: false,
|
|
|
|
wrapClassName: this.wrapClassName,
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
return <Drawer {...drawerProps}>Here is content of Drawer</Drawer>;
|
2018-09-05 13:28:54 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
describe('Drawer', () => {
|
|
|
|
it('render correctly', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
visible: true,
|
|
|
|
width: 400,
|
|
|
|
getContainer: false,
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: ['Here is content of Drawer'],
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
const wrapper = mount(Drawer, props);
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
2018-12-08 11:07:04 +00:00
|
|
|
it('render top drawer', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
visible: true,
|
|
|
|
height: 400,
|
|
|
|
placement: 'top',
|
|
|
|
getContainer: false,
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: 'Here is content of Drawer',
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
const wrapper = mount(Drawer, props);
|
2018-12-08 11:07:04 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-12-08 11:07:04 +00:00
|
|
|
|
2018-09-05 13:28:54 +00:00
|
|
|
it('have a title', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
visible: true,
|
|
|
|
title: 'Test Title',
|
|
|
|
getContainer: false,
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: 'Here is content of Drawer',
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
const wrapper = mount(Drawer, props);
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('closable is false', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
visible: true,
|
|
|
|
closable: false,
|
|
|
|
getContainer: false,
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: 'Here is content of Drawer',
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
const wrapper = mount(Drawer, props);
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('destroyOnClose is true', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
destroyOnClose: true,
|
|
|
|
closable: false,
|
|
|
|
getContainer: false,
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
default: 'Here is content of Drawer',
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
const wrapper = mount(Drawer, props);
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-09-05 13:28:54 +00:00
|
|
|
|
|
|
|
it('class is test_drawer', async () => {
|
|
|
|
const props = {
|
|
|
|
propsData: {
|
|
|
|
wrapClassName: 'test_drawer',
|
|
|
|
},
|
|
|
|
sync: false,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
|
|
|
const wrapper = mount(DrawerCom, props);
|
2018-09-05 13:28:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|