2018-05-13 15:11:51 +00:00
|
|
|
import moment from 'moment'
|
|
|
|
import MockDate from 'mockdate'
|
2018-06-06 02:48:15 +00:00
|
|
|
import Vue from 'vue'
|
2018-05-13 15:11:51 +00:00
|
|
|
|
|
|
|
export function setMockDate (dateString = '2017-09-18T03:30:07.795') {
|
|
|
|
MockDate.set(moment(dateString))
|
|
|
|
}
|
|
|
|
|
|
|
|
export function resetMockDate () {
|
|
|
|
MockDate.reset()
|
|
|
|
}
|
2018-06-06 02:48:15 +00:00
|
|
|
|
|
|
|
export function asyncExpect (fn, timeout) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
if (typeof timeout === 'number') {
|
|
|
|
setTimeout(() => {
|
|
|
|
fn()
|
|
|
|
resolve()
|
|
|
|
}, timeout)
|
|
|
|
} else {
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
fn()
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|