skipped specs mean yellow star
This commit is contained in:
parent
8fbf3ba859
commit
c485c33a3c
|
@ -1,31 +1,18 @@
|
||||||
describe("TrivialNodeReporter", function() {
|
describe("TrivialNodeReporter", function() {
|
||||||
|
|
||||||
|
|
||||||
function green(str) {
|
//keep these literal. otherwise the test loses value as a test.
|
||||||
return '\033[32m' + str + '\033[0m'; //keep these literal. otherwise the test loses value as a test.
|
function green(str) { return '\033[32m' + str + '\033[0m'; }
|
||||||
}
|
function red(str) { return '\033[31m' + str + '\033[0m'; }
|
||||||
|
function yellow(str) { return '\033[33m' + str + '\033[0m'; }
|
||||||
function red(str) {
|
|
||||||
return '\033[31m' + str + '\033[0m';
|
|
||||||
}
|
|
||||||
|
|
||||||
var newline = "\n";
|
var newline = "\n";
|
||||||
|
|
||||||
var passingSpec = {
|
var passingSpec = { results: function(){ return {passed:function(){return true;}}; } },
|
||||||
results: function(){
|
failingSpec = { results: function(){ return {passed:function(){return false;}}; } },
|
||||||
return {passed:function(){return true;}};
|
skippedSpec = { results: function(){ return {skipped:true}; } };
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var failingSpec = {
|
function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); }
|
||||||
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) {
|
function repeat(thing, times) {
|
||||||
var arr = [];
|
var arr = [];
|
||||||
|
@ -33,8 +20,8 @@ describe("TrivialNodeReporter", function() {
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fiftyRedFs = repeat(red("F"), 50).join("");
|
var fiftyRedFs = repeat(red("F"), 50).join(""),
|
||||||
var fiftyGreenDots = repeat(green("."), 50).join("");
|
fiftyGreenDots = repeat(green("."), 50).join("");
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.fakeSys = (function(){
|
this.fakeSys = (function(){
|
||||||
|
@ -46,30 +33,9 @@ describe("TrivialNodeReporter", function() {
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
this.env = new jasmine.Env();
|
|
||||||
this.env.updateInterval = 0;
|
|
||||||
|
|
||||||
this.reporter = new jasmine.TrivialNodeReporter(this.fakeSys);
|
this.reporter = new jasmine.TrivialNodeReporter(this.fakeSys);
|
||||||
});
|
});
|
||||||
|
|
||||||
// reportSpecResults: function(spec) {
|
|
||||||
// var result = spec.results();
|
|
||||||
// var msg = '';
|
|
||||||
// if (result.passed())
|
|
||||||
// {
|
|
||||||
// msg = (colors) ? (ansi.green + '.' + ansi.none) : '.';
|
|
||||||
// // } else if (result.skipped) { TODO: Research why "result.skipped" returns false when "xit" is called on a spec?
|
|
||||||
// // msg = (colors) ? (ansi.yellow + '*' + ansi.none) : '*';
|
|
||||||
// } else {
|
|
||||||
// msg = (colors) ? (ansi.red + 'F' + ansi.none) : 'F';
|
|
||||||
// }
|
|
||||||
// sys.print(msg);
|
|
||||||
// if (columnCounter++ < 50) return;
|
|
||||||
// columnCounter = 0;
|
|
||||||
// sys.print('\n');
|
|
||||||
// },
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe('A Test Run', function(){
|
describe('A Test Run', function(){
|
||||||
|
|
||||||
|
@ -83,17 +49,20 @@ describe("TrivialNodeReporter", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prints a red dot if the spec fails", function(){
|
it("prints a red dot if the spec fails", function(){
|
||||||
var failingSpec = {
|
|
||||||
results: function(){
|
|
||||||
return {passed:function(){return false;}};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.reporter.reportSpecResults(failingSpec);
|
this.reporter.reportSpecResults(failingSpec);
|
||||||
|
|
||||||
expect(this.fakeSys.getOutput()).toEqual(
|
expect(this.fakeSys.getOutput()).toEqual(
|
||||||
red("F")
|
red("F")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("prints a yellow star if the spec was skipped", function(){
|
||||||
|
this.reporter.reportSpecResults(skippedSpec);
|
||||||
|
|
||||||
|
expect(this.fakeSys.getOutput()).toEqual(
|
||||||
|
yellow("*")
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,6 +82,7 @@ describe("TrivialNodeReporter", function() {
|
||||||
|
|
||||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 48);
|
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 48);
|
||||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(passingSpec);}, 2);
|
repeatedlyInvoke(function(){self.reporter.reportSpecResults(passingSpec);}, 2);
|
||||||
|
|
||||||
expect(this.fakeSys.getOutput()).
|
expect(this.fakeSys.getOutput()).
|
||||||
toEqual(fiftyRedFs + newline +
|
toEqual(fiftyRedFs + newline +
|
||||||
fiftyRedFs + newline +
|
fiftyRedFs + newline +
|
||||||
|
|
|
@ -15,9 +15,10 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||||
function redStr(str) { return coloredStr("red", str); }
|
function redStr(str) { return coloredStr("red", str); }
|
||||||
function yellowStr(str) { return coloredStr("yellow", str); }
|
function yellowStr(str) { return coloredStr("yellow", str); }
|
||||||
|
|
||||||
function greenDot() { sys.print(greenStr(".")); }
|
function greenDot() { sys.print(greenStr(".")); }
|
||||||
function redF() { sys.print(redStr("F")); }
|
function redF() { sys.print(redStr("F")); }
|
||||||
function newline() { sys.print("\n"); }
|
function yellowStar() { sys.print(yellowStr("*")); }
|
||||||
|
function newline() { sys.print("\n"); }
|
||||||
|
|
||||||
|
|
||||||
function lineEnder(columnsPerLine) {
|
function lineEnder(columnsPerLine) {
|
||||||
|
@ -34,7 +35,10 @@ jasmine.TrivialNodeReporter = function(sys) {
|
||||||
var startNewLineIfNecessary = lineEnder(defaultColumnsPerLine);
|
var startNewLineIfNecessary = lineEnder(defaultColumnsPerLine);
|
||||||
|
|
||||||
this.reportSpecResults = function(spec) {
|
this.reportSpecResults = function(spec) {
|
||||||
if (spec.results().passed()) {
|
var results = spec.results();
|
||||||
|
if (results.skipped) {
|
||||||
|
yellowStar();
|
||||||
|
} else if (results.passed()) {
|
||||||
greenDot();
|
greenDot();
|
||||||
} else {
|
} else {
|
||||||
redF();
|
redF();
|
||||||
|
|
Loading…
Reference in New Issue