integrated trivial console into a real-world situation and dicovered a couple mistakes/misses

This commit is contained in:
Steve Conover 2011-02-28 23:17:39 -08:00
parent f5afe18a6b
commit 88ee377662
2 changed files with 11 additions and 9 deletions

View File

@ -14,8 +14,8 @@ describe("TrivialConsoleReporter", function() {
var passingSpec = { results: function(){ return {passed: function(){return true;}}; } }, var passingSpec = { results: function(){ return {passed: function(){return true;}}; } },
failingSpec = { results: function(){ return {passed: function(){return false;}}; } }, 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, specs: function(){return [null, null, null];}}; } }, passingRun = { results: function(){ return {failedCount: 0, items_: [null, null, null]}; } },
failingRun = { results: function(){ return {failedCount: 7, specs: function(){return [null, null, null];}}; } }; failingRun = { results: function(){ return {failedCount: 7, items_: [null, null, null]}; } };
function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); } function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); }
@ -59,7 +59,7 @@ describe("TrivialConsoleReporter", function() {
{ {
results:function(){ results:function(){
return { return {
specs: function(){return [null, null, null];}, items_: [null, null, null],
totalCount: 7, totalCount: 7,
failedCount: 0 failedCount: 0
}; };
@ -87,7 +87,7 @@ describe("TrivialConsoleReporter", function() {
{ {
results:function(){ results:function(){
return { return {
specs: function(){return [null, null, null];}, items_: [null, null, null],
totalCount: 7, totalCount: 7,
failedCount: 0 failedCount: 0
}; };
@ -155,7 +155,7 @@ describe("TrivialConsoleReporter", function() {
{ {
results:function(){ results:function(){
return { return {
specs: function(){return [null, null, null];}, items_: [null, null, null],
totalCount: 7, totalCount: 7,
failedCount: 2 failedCount: 2
}; };
@ -385,7 +385,7 @@ describe("TrivialConsoleReporter", function() {
describe("specs/assertions/failures summary", function(){ describe("specs/assertions/failures summary", function(){
it("prints statistics in green if there were no failures", function() { it("prints statistics in green if there were no failures", function() {
this.reporter.reportRunnerResults({ this.reporter.reportRunnerResults({
results:function(){return {specs: function(){return [null, null, null];}, totalCount: 7, failedCount: 0};} results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
}); });
expect(this.out.getOutput()). expect(this.out.getOutput()).
toContain("3 specs, 7 assertions, 0 failures"); toContain("3 specs, 7 assertions, 0 failures");
@ -393,7 +393,7 @@ describe("TrivialConsoleReporter", function() {
it("prints statistics in red if there was a failure", function() { it("prints statistics in red if there was a failure", function() {
this.reporter.reportRunnerResults({ this.reporter.reportRunnerResults({
results:function(){return {specs: function(){return [null, null, null];}, totalCount: 7, failedCount: 3};} results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 3};}
}); });
expect(this.out.getOutput()). expect(this.out.getOutput()).
toContain("3 specs, 7 assertions, 3 failures"); toContain("3 specs, 7 assertions, 3 failures");
@ -401,7 +401,7 @@ describe("TrivialConsoleReporter", function() {
it("handles pluralization with 1's ones appropriately", function() { it("handles pluralization with 1's ones appropriately", function() {
this.reporter.reportRunnerResults({ this.reporter.reportRunnerResults({
results:function(){return {specs: function(){return [null];}, totalCount: 1, failedCount: 1};} results:function(){return {items_: [null], totalCount: 1, failedCount: 1};}
}); });
expect(this.out.getOutput()). expect(this.out.getOutput()).
toContain("1 spec, 1 assertion, 1 failure"); toContain("1 spec, 1 assertion, 1 failure");

View File

@ -85,6 +85,8 @@ jasmine.TrivialConsoleReporter = function(print) {
started(); started();
}; };
this.reportSpecStarting = function() { /* do nothing */ };
this.reportSpecResults = function(spec) { this.reportSpecResults = function(spec) {
var results = spec.results(); var results = spec.results();
if (results.skipped) { if (results.skipped) {
@ -135,6 +137,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.specs().length, results.totalCount, results.failedCount); summaryFunction(results.items_.length, results.totalCount, results.failedCount);
}; };
}; };