fix(Toast): closeOnClickOverlay not work (#8044)

* fix(Toast): closeOnClickOverlay not work

* fix: demo
This commit is contained in:
neverland
2021-01-31 16:11:49 +08:00
committed by GitHub
parent 6a3d716f6e
commit 0f3610bafe
3 changed files with 31 additions and 17 deletions
-17
View File
@@ -166,23 +166,6 @@ test('should trigger onClose callback after closed', () => {
Toast.allowMultiple(false);
});
test('closeOnClick option', async () => {
Toast.allowMultiple();
const toast = Toast({
message: 'toast',
});
await later();
toast.$el.click();
expect(toast.value).toBeTruthy();
toast.closeOnClick = true;
toast.$el.click();
expect(toast.value).toBeFalsy();
Toast.allowMultiple(false);
});
test('register component', () => {
Vue.use(Toast);
expect(Vue.component(ToastVue.name)).toBeTruthy();
+24
View File
@@ -15,3 +15,27 @@ test('should change overlay style after using overlay-style prop', async () => {
await later();
expect(wrapper.find('.van-overlay').element.style.background).toEqual('red');
});
test('should close Toast when using closeOnClick prop and clicked', () => {
const wrapper = mount(Toast, {
props: {
show: true,
closeOnClick: true,
},
});
wrapper.find('.van-toast').trigger('click');
expect(wrapper.emitted('update:show')[0][0]).toEqual(false);
});
test('should close Toast when using closeOnClickOverlay prop and overlay is clicked', () => {
const wrapper = mount(Toast, {
props: {
show: true,
closeOnClickOverlay: true,
},
});
wrapper.find('.van-overlay').trigger('click');
expect(wrapper.emitted('update:show')[0][0]).toEqual(false);
});