newline at 50 characters
This commit is contained in:
@@ -11,6 +11,31 @@ describe("TrivialNodeReporter", function() {
|
||||
|
||||
var newline = "\n";
|
||||
|
||||
var passingSpec = {
|
||||
results: function(){
|
||||
return {passed:function(){return true;}};
|
||||
}
|
||||
};
|
||||
|
||||
var failingSpec = {
|
||||
results: function(){
|
||||
return {passed:function(){return false;}};
|
||||
}
|
||||
};
|
||||
|
||||
function repeatedlyInvoke(f, times) {
|
||||
for(var i=0; i<times; i++) f(times+1);
|
||||
}
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for(var i=0; i<times; i++) arr.push(thing);
|
||||
return arr;
|
||||
}
|
||||
|
||||
var fiftyRedFs = repeat(red("F"), 50).join("");
|
||||
var fiftyGreenDots = repeat(green("."), 50).join("");
|
||||
|
||||
beforeEach(function() {
|
||||
this.fakeSys = (function(){
|
||||
var output = "";
|
||||
@@ -49,13 +74,7 @@ describe("TrivialNodeReporter", function() {
|
||||
describe('A Test Run', function(){
|
||||
|
||||
describe('A spec runs', function(){
|
||||
|
||||
it("prints a green dot if the spec passes", function(){
|
||||
var passingSpec = {
|
||||
results: function(){
|
||||
return {passed:function(){return true;}};
|
||||
}
|
||||
};
|
||||
this.reporter.reportSpecResults(passingSpec);
|
||||
|
||||
expect(this.fakeSys.getOutput()).toEqual(
|
||||
@@ -75,7 +94,30 @@ describe("TrivialNodeReporter", function() {
|
||||
red("F")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('many specs run', function(){
|
||||
it("starts a new line every 50 specs", function(){
|
||||
var self = this;
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 49);
|
||||
|
||||
expect(this.fakeSys.getOutput()).
|
||||
toEqual(repeat(red("F"), 49).join(""));
|
||||
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 3);
|
||||
|
||||
expect(this.fakeSys.getOutput()).
|
||||
toEqual(fiftyRedFs + newline +
|
||||
red("F") + red("F"));
|
||||
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 48);
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(passingSpec);}, 2);
|
||||
expect(this.fakeSys.getOutput()).
|
||||
toEqual(fiftyRedFs + newline +
|
||||
fiftyRedFs + newline +
|
||||
green(".") + green("."));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user