integration tests - passing scenarios

This commit is contained in:
Steve Conover 2011-02-28 17:50:16 -08:00
parent b1dceeacd4
commit ac00d765d2
2 changed files with 83 additions and 2 deletions

View File

@ -28,6 +28,15 @@ describe("TrivialNodeReporter", function() {
var fiftyRedFs = repeat(red("F"), 50).join(""),
fiftyGreenDots = repeat(green("."), 50).join("");
function simulateRun(reporter, specResults, suiteResults, finalRunner, startTime, endTime) {
reporter.reportRunnerStarting();
for(var i=0; i<specResults.length; i++) reporter.reportSpecResults(specResults[i]);
for(i=0; i<suiteResults.length; i++) reporter.reportSuiteResults(suiteResults[i]);
reporter.runnerStartTime = startTime;
reporter.now = function(){return endTime;};
reporter.reportRunnerResults(finalRunner);
}
beforeEach(function() {
this.fakeSys = (function(){
var output = "";
@ -43,6 +52,75 @@ describe("TrivialNodeReporter", function() {
});
describe('Integration test', function(){
it("prints the proper output under a pass scenario. small numbers.", function(){
simulateRun(this.reporter,
repeat(passingSpec, 3),
[],
{
results:function(){
return {
specs: function(){return [null, null, null];},
totalCount: 7,
failedCount: 0
};
}
},
1000,
1777);
expect(this.fakeSys.getOutput()).toEqual(
[
"Started",
green(".") + green(".") + green("."),
"",
"Finished in 0.777 seconds",
green("3 specs, 7 assertions, 0 failures"),
""
].join("\n") + "\n"
);
});
it("prints the proper output under a pass scenario. large numbers.", function(){
simulateRun(this.reporter,
repeat(passingSpec, 57),
[],
{
results:function(){
return {
specs: function(){return [null, null, null];},
totalCount: 7,
failedCount: 0
};
}
},
1000,
1777);
expect(this.fakeSys.getOutput()).toEqual(
[
"Started",
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") + "\n" +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green("."),
"",
"Finished in 0.777 seconds",
green("3 specs, 7 assertions, 0 failures"),
""
].join("\n") + "\n"
);
});
});
describe('A Test Run', function(){
describe('Starts', function(){

View File

@ -39,11 +39,14 @@ jasmine.TrivialNodeReporter = function(sys) {
newline();
}
}
function finished(elapsed) { newline(); sys.print("Finished in " + elapsed/1000 + " seconds"); }
function finished(elapsed) { newline();
newline();
sys.print("Finished in " + elapsed/1000 + " seconds"); }
function summary(colorF, specs, assertions, failed) { newline();
colorF(sys.print(specs + " " + plural(language.spec, specs) + ", " +
sys.print(colorF(specs + " " + plural(language.spec, specs) + ", " +
assertions + " " + plural(language.assertion, assertions) + ", " +
failed + " " + plural(language.failure, failed)));
newline();
newline(); }
function greenSummary(specs, assertions, failed){ summary(greenStr, specs, assertions, failed); }
function redSummary(specs, assertions, failed){ summary(redStr, specs, assertions, failed); }