run result - passed green, failed red
This commit is contained in:
parent
e6a080039f
commit
e8c8a0bdfd
@ -6,11 +6,16 @@ describe("TrivialNodeReporter", function() {
|
||||
function red(str) { return '\033[31m' + str + '\033[0m'; }
|
||||
function yellow(str) { return '\033[33m' + str + '\033[0m'; }
|
||||
|
||||
function prefixGreen(str) { return '\033[32m' + str; }
|
||||
function prefixRed(str) { return '\033[31m' + str; }
|
||||
|
||||
var newline = "\n";
|
||||
|
||||
var passingSpec = { results: function(){ return {passed:function(){return true;}}; } },
|
||||
failingSpec = { results: function(){ return {passed:function(){return false;}}; } },
|
||||
skippedSpec = { results: function(){ return {skipped:true}; } };
|
||||
skippedSpec = { results: function(){ return {skipped:true}; } },
|
||||
passingRun = { results: function(){ return {failedCount: 0}; } },
|
||||
failingRun = { results: function(){ return {failedCount: 7}; } };
|
||||
|
||||
function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); }
|
||||
|
||||
@ -100,6 +105,25 @@ describe("TrivialNodeReporter", function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Finishes', function(){
|
||||
it("prints Finished in green if the test run succeeded", function(){
|
||||
this.reporter.reportRunnerResults(passingRun);
|
||||
|
||||
expect(this.fakeSys.getOutput()).toContain(
|
||||
newline + prefixGreen("Finished")
|
||||
);
|
||||
});
|
||||
|
||||
it("prints Finished in red if the test run failed", function(){
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
|
||||
expect(this.fakeSys.getOutput()).toContain(
|
||||
newline + prefixRed("Finished")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
@ -15,11 +15,16 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||
function redStr(str) { return coloredStr("red", str); }
|
||||
function yellowStr(str) { return coloredStr("yellow", str); }
|
||||
|
||||
function newline() { sys.print("\n"); }
|
||||
function started() { sys.print("Started"); newline(); }
|
||||
function greenDot() { sys.print(greenStr(".")); }
|
||||
function redF() { sys.print(redStr("F")); }
|
||||
function yellowStar() { sys.print(yellowStr("*")); }
|
||||
function newline() { sys.print("\n"); }
|
||||
function started() { sys.print("Started"); newline(); }
|
||||
|
||||
function greenDot() { sys.print(greenStr(".")); }
|
||||
function redF() { sys.print(redStr("F")); }
|
||||
function yellowStar() { sys.print(yellowStr("*")); }
|
||||
|
||||
function finished(colorF) { newline(); sys.print(colorF("Finished")); }
|
||||
function greenFinished() { finished(greenStr); }
|
||||
function redFinished() { finished(redStr); }
|
||||
|
||||
|
||||
|
||||
@ -52,4 +57,12 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||
}
|
||||
startNewLineIfNecessary();
|
||||
};
|
||||
|
||||
this.reportRunnerResults = function(runner) {
|
||||
if (runner.results().failedCount === 0) {
|
||||
greenFinished();
|
||||
} else {
|
||||
redFinished();
|
||||
}
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user