forked from iefserge/test-plan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (26 loc) · 746 Bytes
/
index.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
// Original author
// http://dailyjs.com/2013/11/14/mocha-assertion-counting/
var assert = require('assert');
var deprecate = require('depd')('plando')
exports = module.exports = plan;
exports.plan = deprecate.function(plan, 'ok: Use require(\'plando\')(count, done)');
function plan(count, done) {
if (0 === count) return done();
function ok(expression) {
assert(expression);
if (count === 0) {
assert(false, 'Too many assertions called');
} else {
count--;
}
if (count === 0) {
done();
}
}
function d() {
return ok(true);
}
d.ok = ok;
d.check = deprecate.function(d, 'check: Use returned function');
return d;
}