-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroast.js
38 lines (31 loc) · 879 Bytes
/
roast.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
"use strict";
function Roast(consoleObject) {
this.tests = [];
this.hasFailingTests = false;
this.console = consoleObject || console;
};
Roast.prototype.it = function it(description, testFunction) {
this.tests.push({
description : description,
testFunction : testFunction
});
};
Roast.prototype.run = function run() {
var testedCount = 0;
this.tests.forEach(function runTest(test) {
var result = test.testFunction();
if (result !== true) {
this.hasFailingTests = true;
this.console.error("Failed: [" + test.description + "]");
}
testedCount++;
}, this);
this.console.log("Roasted " + testedCount + " tests.");
};
Roast.prototype.exit = function exit() {
if (this.hasFailingTests) {
process.exit(1);
}
process.exit(0);
};
module.exports = Roast;