ant-design-vue/tests/utils.js

28 lines
542 B
JavaScript
Raw Normal View History

2019-01-12 11:33:27 +08:00
import moment from 'moment';
import MockDate from 'mockdate';
import Vue from 'vue';
2018-05-13 23:11:51 +08:00
2019-01-12 11:33:27 +08:00
export function setMockDate(dateString = '2017-09-18T03:30:07.795') {
MockDate.set(moment(dateString));
2018-05-13 23:11:51 +08:00
}
2019-01-12 11:33:27 +08:00
export function resetMockDate() {
MockDate.reset();
2018-05-13 23:11:51 +08:00
}
2019-01-12 11:33:27 +08:00
export function asyncExpect(fn, timeout) {
return new Promise(resolve => {
if (typeof timeout === 'number') {
setTimeout(() => {
2019-01-12 11:33:27 +08:00
fn();
resolve();
}, timeout);
} else {
Vue.nextTick(() => {
2019-01-12 11:33:27 +08:00
fn();
resolve();
});
}
2019-01-12 11:33:27 +08:00
});
}