[Test] optimize async cases (#1232)

This commit is contained in:
neverland
2018-06-06 20:13:24 +08:00
committed by GitHub
parent 25bd67e8f1
commit 74aa001bb6
10 changed files with 127 additions and 137 deletions

View File

@@ -2,6 +2,7 @@ import ContactCard from '..';
import ContactList from '../../contact-list';
import ContactEdit from '../../contact-edit';
import { mount } from '@vue/test-utils';
import { later } from '../../../test/utils';
const contactInfo = {
name: 'test',
@@ -93,7 +94,7 @@ describe('ContactEdit', () => {
expect(wrapper.vm.data.name).toEqual('123');
});
test('delete contact', done => {
test('delete contact', async() => {
const wrapper = mount(ContactEdit, {
propsData: {
isEdit: true
@@ -104,9 +105,7 @@ describe('ContactEdit', () => {
deleteButton.trigger('click');
document.querySelector('.van-dialog__confirm').click();
setTimeout(() => {
expect(wrapper.emitted('delete')).toBeTruthy();
done();
});
await later();
expect(wrapper.emitted('delete')).toBeTruthy();
});
});