mirror of
https://github.com/vuejs/vue.git
synced 2024-11-22 04:39:46 +00:00
37 lines
747 B
TypeScript
37 lines
747 B
TypeScript
// wrap tests to support test('foo', done => {...}) interface
|
|
const _test = test
|
|
|
|
const wait = (): [() => void, Promise<void>] => {
|
|
let done
|
|
const p = new Promise<void>((resolve, reject) => {
|
|
done = resolve
|
|
done.fail = reject
|
|
})
|
|
return [done, p]
|
|
}
|
|
|
|
const shimmed =
|
|
((global as any).it =
|
|
(global as any).test =
|
|
(desc: string, fn?: any, timeout?: number) => {
|
|
if (fn && fn.length > 0) {
|
|
_test(
|
|
desc,
|
|
() => {
|
|
const [done, p] = wait()
|
|
fn(done)
|
|
return p
|
|
},
|
|
timeout
|
|
)
|
|
} else {
|
|
_test(desc, fn, timeout)
|
|
}
|
|
})
|
|
|
|
;['skip', 'only', 'todo', 'concurrent'].forEach(key => {
|
|
shimmed[key] = _test[key]
|
|
})
|
|
|
|
export {}
|