-
Notifications
You must be signed in to change notification settings - Fork 4
/
mocha.js
31 lines (28 loc) · 903 Bytes
/
mocha.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
/**
* Mocha interop, assumes "it" is a globally defined function.
*/
/*eslint-env mocha */
var checkers = require("./");
exports = module.exports = checking;
exports.gen = checkers.gen;
/**
* Generate a mocha example
* @param {string} desc The example description
* @param {array} args List of generators to pass to body
* @param {function} body Function to check, should return true or false
* @param {number} n The number of iterations to check (optional)
* @param {object} options Additional options for check (optional)
*/
function checking(desc, args, body, n, options) {
if (typeof n === 'undefined') {
n = 1000;
options = {};
}
if (typeof options === 'undefined' && typeof n !== 'number') {
options = n;
n = 1000;
}
it(desc, function() {
checkers.forAll(args, body).check(n, options);
});
}