run result - passed green, failed red

This commit is contained in:
Steve Conover
2011-02-28 15:13:46 -08:00
parent e6a080039f
commit e8c8a0bdfd
2 changed files with 43 additions and 6 deletions

View File

@@ -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); }
@@ -99,6 +104,25 @@ describe("TrivialNodeReporter", function() {
green(".") + green("."));
});
});
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")
);
});
});
});