-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
49 lines (45 loc) · 867 Bytes
/
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
var setAsap = require('../setAsap');
var painless = require('painless');
var assert = painless.assert;
var test = painless.createGroup();
test('Is async', function(done) {
var async = false;
setAsap(function() {
assert.equal(async, true);
done();
});
async = true;
});
test('Multiple calls at the same time', function(done) {
var async1 = false,
async2 = false,
done1 = false,
done2 = false;
setAsap(function() {
assert.equal(async1, true);
done1 = true;
checkDone();
});
setAsap(function() {
assert.equal(async2, true);
done2 = true;
checkDone();
});
function checkDone() {
if(done1 && done2) {
done();
}
}
async1 = true;
async2 = true;
});
test('Calls in order', function(done) {
var async1 = false;
setAsap(function() {
setAsap(function() {
assert.equal(async1, true);
done();
});
});
async1 = true;
});