This commit is contained in:
Steve Conover 2011-02-28 16:54:38 -08:00
parent 882c287191
commit 9704550b33
1 changed files with 11 additions and 8 deletions

View File

@ -9,6 +9,12 @@ jasmine.TrivialNodeReporter = function(sys) {
var defaultColumnsPerLine = 50; var defaultColumnsPerLine = 50;
var language = {
spec:"spec",
assertion:"assertion",
failure:"failure"
};
function coloredStr(color, str) { return ansi[color] + str + ansi.none; } function coloredStr(color, str) { return ansi[color] + str + ansi.none; }
function greenStr(str) { return coloredStr("green", str); } function greenStr(str) { return coloredStr("green", str); }
@ -26,9 +32,9 @@ jasmine.TrivialNodeReporter = function(sys) {
function finished(elapsed) { newline(); sys.print("Finished in " + elapsed/1000 + " seconds"); } function finished(elapsed) { newline(); sys.print("Finished in " + elapsed/1000 + " seconds"); }
function summary(colorF, specs, assertions, failed) { newline(); function summary(colorF, specs, assertions, failed) { newline();
colorF(sys.print(specs + " " + plural("spec", specs) + ", " + colorF(sys.print(specs + " " + plural(language.spec, specs) + ", " +
assertions + " " + plural("assertion", assertions) + ", " + assertions + " " + plural(language.assertion, assertions) + ", " +
failed + " " + plural("failure", failed))); } failed + " " + plural(language.failure, failed))); }
function greenSummary(specs, assertions, failed){ summary(greenStr, specs, assertions, failed); } function greenSummary(specs, assertions, failed){ summary(greenStr, specs, assertions, failed); }
function redSummary(specs, assertions, failed){ summary(redStr, specs, assertions, failed); } function redSummary(specs, assertions, failed){ summary(redStr, specs, assertions, failed); }
@ -92,10 +98,7 @@ jasmine.TrivialNodeReporter = function(sys) {
finished(this.now() - this.runnerStartTime); finished(this.now() - this.runnerStartTime);
var results = runner.results(); var results = runner.results();
if (results.failedCount === 0) { var summaryFunction = results.failedCount === 0 ? greenSummary : redSummary;
greenSummary(results.specs().length, results.totalCount, results.failedCount); summaryFunction(results.specs().length, results.totalCount, results.failedCount);
} else {
redSummary(results.specs().length, results.totalCount, results.failedCount);
}
}; };
}; };