-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
89 lines (78 loc) · 2.59 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var NoAsync = require('./');
function testEquals(name, a, b) {
if (a.toString() === b.toString()) {
console.log('√ – ' + name);
} else {
console.error('x – ' + name);
}
}
NoAsync.series([
function(next) { next(null, 1); },
function(next) { next(null, 2); },
function(next) { next(null, 3); }
], function seriesComplete(err, arrayOfResponses) {
testEquals('series', arrayOfResponses, [1, 2, 3]);
});
NoAsync.parallel([
function(next) { next(null, 1); },
function(next) { next(null, 2); },
function(next) { next(null, 3); }
], function parallelComplete(arrayOfErrors, arrayOfResponses) {
testEquals('parallel', arrayOfResponses, [1, 2, 3]);
});
NoAsync.eachSeries(
[1, 2, 3],
function(i, next) { next(null, i); },
function eachSeriesComplete(err, arrayOfResponses) {
testEquals('eachSeries', arrayOfResponses, [1, 2, 3]);
}
);
NoAsync.eachSeries(
[],
function(i, next) { next(null, i); },
function eachSeriesComplete(err, arrayOfResponses) {
testEquals('eachSeriesEmpty', arrayOfResponses, []);
}
);
NoAsync.eachParallel(
[1, 2, 3],
function(i, next) { next(null, i); },
function eachParallelComplete(arrayOfErrors, arrayOfResponses) {
testEquals('eachParallel', arrayOfResponses, [1, 2, 3]);
}
);
NoAsync.eachParallel(
[],
function(i, next) { next(null, i); },
function eachParallelComplete(arrayOfErrors, arrayOfResponses) {
testEquals('eachParallelEmpty', arrayOfResponses, []);
}
);
NoAsync.eachSeries(
{ 1: 'one', 2: 'two', 3: 'three' },
function(key, value, next) { next(null, [key, value]); },
function eachObjectSeriesComplete(arrayOfErrors, arrayOfResponses) {
testEquals('eachObjectSeries', arrayOfResponses, [[1, 'one'], [2, 'two'], [3, 'three']]);
}
);
NoAsync.eachSeries(
{},
function(key, value, next) { next(null, [key, value]); },
function eachObjectSeriesComplete(arrayOfErrors, arrayOfResponses) {
testEquals('eachObjectSeriesEmpty', arrayOfResponses, []);
}
);
NoAsync.eachParallel(
{ 1: 'one', 2: 'two', 3: 'three' },
function(key, value, next) { next(null, [key, value]); },
function eachObjectParallelComplete(arrayOfErrors, arrayOfResponses) {
testEquals('eachObjectParallel', arrayOfResponses, [[1, 'one'], [2, 'two'], [3, 'three']]);
}
);
NoAsync.eachParallel(
{},
function(key, value, next) { next(null, [key, value]); },
function eachObjectParallelComplete(arrayOfErrors, arrayOfResponses) {
testEquals('eachObjectParallelEmpty', arrayOfResponses, []);
}
);