call back when done

This commit is contained in:
Steve Conover 2011-02-28 23:58:06 -08:00
parent 88ee377662
commit a1ba43c864
2 changed files with 19 additions and 3 deletions

View File

@ -47,7 +47,11 @@ describe("TrivialConsoleReporter", function() {
}; };
})(); })();
this.reporter = new jasmine.TrivialConsoleReporter(this.out.print); this.done = false
var self = this
this.reporter = new jasmine.TrivialConsoleReporter(this.out.print, function(runner){
self.done = true
});
}); });
@ -408,6 +412,16 @@ describe("TrivialConsoleReporter", function() {
}); });
}); });
describe("done callback", function(){
it("calls back when done", function() {
expect(this.done).toBeFalsy();
this.reporter.reportRunnerResults({
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
});
expect(this.done).toBeTruthy();
});
});
}); });
}); });

View File

@ -1,8 +1,9 @@
jasmine.TrivialConsoleReporter = function(print) { jasmine.TrivialConsoleReporter = function(print, doneCallback) {
//inspired by mhevery's jasmine-node reporter //inspired by mhevery's jasmine-node reporter
//https://github.com/mhevery/jasmine-node //https://github.com/mhevery/jasmine-node
doneCallback = doneCallback || function(){};
var defaultColumnsPerLine = 50, var defaultColumnsPerLine = 50,
ansi = { green: '\033[32m', red: '\033[31m', yellow: '\033[33m', none: '\033[0m' }, ansi = { green: '\033[32m', red: '\033[31m', yellow: '\033[33m', none: '\033[0m' },
language = { spec:"spec", assertion:"assertion", failure:"failure" }; language = { spec:"spec", assertion:"assertion", failure:"failure" };
@ -138,5 +139,6 @@ jasmine.TrivialConsoleReporter = function(print) {
var results = runner.results(); var results = runner.results();
var summaryFunction = results.failedCount === 0 ? greenSummary : redSummary; var summaryFunction = results.failedCount === 0 ? greenSummary : redSummary;
summaryFunction(results.items_.length, results.totalCount, results.failedCount); summaryFunction(results.items_.length, results.totalCount, results.failedCount);
doneCallback(runner);
}; };
}; };