delay

说明

延迟wait毫秒后执行处理器callback

源码

用法

delay.test.ts
1
import { delay } from "../../utility/function/delay";
2
3
describe('delay', () => {
4
test('delay should fire the callback after wait ms', () => {
5
const received = function () {
6
expect(true).toBeTruthy();
7
}
8
9
delay(received, 500);
10
});
11
12
test('delay should receive params that passed', () => {
13
const received = function (name: string, age: number) {
14
expect(name).toBe('ddzy');
15
expect(age).toBe(21);
16
}
17
18
delay(received, 1000, 'ddzy', 21);
19
});
20
21
test('delay should return the timeout id', () => {
22
const received = function () {
23
expect(true).toBeTruthy();
24
}
25
26
const result = delay(received, 1500);
27
28
expect(typeof result).toBe('number');
29
});
30
});
Copied!
最近更新 1yr ago
复制链接