-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtest-helpers.js
62 lines (57 loc) · 1.02 KB
/
test-helpers.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
58
59
60
61
62
"use strict";
module.exports = {
makeStateChecker: function(assert, done, names){
return {
check: function(assert, value){
var state = names.shift();
assert.equal( state, value, "state check "+state );
if(state !== value) {
done();
}
return state;
},
get: function(){
return names[0];
},
next: function(){
return names.shift();
},
toString: function(){
return this.get();
}
};
},
later: function(fn){
return function(){
setTimeout(fn, 1);
};
},
logErrorAndStart: function(assert, done) {
return function(e) {
assert.ok(false,"Error "+e);
setTimeout(function(){
throw e;
},1);
done();
};
},
getId: function(o){
return o.id;
},
asyncResolve: function(data) {
var def = new Promise(function(resolve){
setTimeout(function(){
resolve(data);
},1);
});
return def;
},
asyncReject: function(data) {
var def = new Promise(function(resolve, reject){
setTimeout(function(){
reject(data);
},1);
});
return def;
}
};