mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:28:37 +08:00
23 lines
699 B
TypeScript
23 lines
699 B
TypeScript
import { RenderOptions } from "../src/factory";
|
|
|
|
// jest.useFakeTimers 会修改 global 的 setTimeout 所以需要把原始的记录下来。
|
|
const timerFn = setTimeout;
|
|
export function wait(duration:number, fn?:Function) {
|
|
return new Promise((resolve) => {
|
|
timerFn(() => {
|
|
fn && fn();
|
|
resolve();
|
|
}, duration);
|
|
});
|
|
}
|
|
|
|
export function makeEnv(env?:Partial<RenderOptions>):RenderOptions {
|
|
return {
|
|
session: 'test-case',
|
|
isCancel: () => false,
|
|
notify: (msg:string) => null,
|
|
jumpTo: (to:string) => console.info('Now should jump to ' + to),
|
|
alert: (msg) => console.info(`Alert: ${msg}`),
|
|
...env
|
|
}
|
|
} |