-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
57 lines (43 loc) · 1.15 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import test from 'ava';
import SetInterval from './src/SetInterval';
test.cb('start interval', t => {
function callback() {
t.true(true);
t.is(typeof SetInterval.key['test'], number);
}
SetInterval.start(callback, 1000, 'test');
setTimeout(t.end);
});
test.cb('clear interval', t => {
function callback() {
t.true(true);
}
SetInterval.start(callback, 1000, 'test');
SetInterval.clear('test');
t.is(SetInterval.key['test'], void 0);
setTimeout(t.end);
});
test.cb('multiple instances', t => {
function callback() {
t.true(true);
}
function callback_2() {
t.true(true);
}
function callback_3() {
t.true(true);
t.is(typeof SetInterval.key['test'], number);
t.is(typeof SetInterval.key['test_2'], number);
t.is(typeof SetInterval.key['test_3'], number);
}
SetInterval.start(callback, 1000, 'test');
SetInterval.start(callback_2, 2000, 'test_2');
SetInterval.start(callback_3, 3000, 'test_3');
SetInterval.clear('test');
SetInterval.clear('test_2');
SetInterval.clear('test_3');
t.is(SetInterval.key['test'], void 0);
t.is(SetInterval.key['test_2'], void 0);
t.is(SetInterval.key['test_3'], void 0);
setTimeout(t.end);
});