feat(Dialog): add open、close event (#4633)

This commit is contained in:
neverland
2019-09-30 10:55:50 +08:00
committed by GitHub
parent 48bd6d86d8
commit 02a81a1ac3
5 changed files with 34 additions and 62 deletions
+16 -8
View File
@@ -1,6 +1,6 @@
import Vue from 'vue';
import Dialog from '..';
import DialogVue from '../Dialog';
import DialogComponent from '../Dialog';
import { mount, later, trigger } from '../../../test/utils';
test('Dialog function call', async () => {
@@ -33,7 +33,7 @@ test('Dialog function call', async () => {
});
test('before close', () => {
const wrapper = mount(DialogVue, {
const wrapper = mount(DialogComponent, {
propsData: {
value: true,
showCancelButton: true,
@@ -72,11 +72,11 @@ test('set default options', () => {
test('register component', () => {
Vue.use(Dialog);
expect(Vue.component(DialogVue.name)).toBeTruthy();
expect(Vue.component(DialogComponent.name)).toBeTruthy();
});
test('button color', () => {
const wrapper = mount(DialogVue, {
const wrapper = mount(DialogComponent, {
propsData: {
value: true,
showCancelButton: true,
@@ -88,7 +88,7 @@ test('button color', () => {
});
test('button text', () => {
const wrapper = mount(DialogVue, {
const wrapper = mount(DialogComponent, {
propsData: {
value: true,
showCancelButton: true,
@@ -100,11 +100,11 @@ test('button text', () => {
});
test('dialog component', () => {
expect(Dialog.Component).toEqual(DialogVue);
expect(Dialog.Component).toEqual(DialogComponent);
});
test('default slot', () => {
const wrapper = mount(DialogVue, {
const wrapper = mount(DialogComponent, {
propsData: {
value: true
},
@@ -116,7 +116,7 @@ test('default slot', () => {
});
test('title slot', () => {
const wrapper = mount(DialogVue, {
const wrapper = mount(DialogComponent, {
propsData: {
value: true
},
@@ -126,3 +126,11 @@ test('title slot', () => {
});
expect(wrapper).toMatchSnapshot();
});
test('open & close event', () => {
const wrapper = mount(DialogComponent);
wrapper.vm.value = true;
expect(wrapper.emitted('open')).toBeTruthy();
wrapper.vm.value = false;
expect(wrapper.emitted('close')).toBeTruthy();
});