-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
35 lines (29 loc) · 697 Bytes
/
test.js
File metadata and controls
35 lines (29 loc) · 697 Bytes
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
var test = require('tape');
var thyme = require('./index');
testMethod('timeout');
testMethod('interval');
test('interval runs more than once', function (t) {
t.plan(4);
var i = 0;
var stop = thyme.interval(function () {
t.pass('interval runs');
if (++i === 3) {
t.pass('stopping timer');
stop();
}
});
});
function testMethod (method) {
test(method, function (t) {
t.plan(2);
var _stop = thyme[method](function () {
t.pass('Timeout runs!');
_stop();
}, 10);
var stop = thyme[method](function () {
t.fail('Timeout should not run!');
}, 10);
t.ok(typeof stop === 'function', 'returns function');
stop();
});
}