[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

@@ -1,3 +1,6 @@
import Vue from 'vue';
import { TransitionStub } from '@vue/test-utils';
// Trigger pointer/touch event
export function trigger(wrapper, eventName, x = 0, y = 0) {
const el = wrapper.element ? wrapper.element : wrapper;
@@ -34,3 +37,14 @@ export function triggerDrag(el, x = 0, y = 0) {
trigger(el, 'touchmove', x, y);
trigger(el, 'touchend', x, y);
}
// promisify setTimeout
export function later(delay) {
return new Promise(function(resolve) {
setTimeout(resolve, delay);
});
}
export function transitionStub() {
Vue.component('transition', TransitionStub);
}