Visually group specs by suite.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
jasmine.TrivialReporter = function() {
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
@@ -25,6 +27,24 @@ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarA
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var suites = runner.getAllSuites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'runSpec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
suite.description);
|
||||
console.log(suite);
|
||||
console.log(suite.getFullName());
|
||||
this.suiteDivs[suite.getFullName()] = suiteDiv;
|
||||
var parentDiv = this.document.body;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
};
|
||||
|
||||
@@ -52,7 +72,7 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(specDiv);
|
||||
this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
@@ -60,7 +80,7 @@ jasmine.TrivialReporter.prototype.log = function() {
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return document.location;
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
@@ -72,7 +92,7 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) > -1;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||
};
|
||||
|
||||
//protect against console.log incidents
|
||||
|
||||
@@ -24,6 +24,12 @@ p {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 2px;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
clear: both;
|
||||
|
||||
@@ -1724,6 +1724,28 @@ jasmine.Runner.prototype.finishCallback = function() {
|
||||
this.env.reporter.reportRunnerResults(this);
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.getAllSuites = function() {
|
||||
var suitesToReturn = [];
|
||||
|
||||
function addSuite(suite) {
|
||||
suitesToReturn.push(suite);
|
||||
|
||||
for (var j = 0; j < suite.specs.length; j++) {
|
||||
var spec = suite.specs[j];
|
||||
if (spec instanceof jasmine.Suite) {
|
||||
addSuite(spec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.suites.length; i++) {
|
||||
var suite = this.suites[i];
|
||||
addSuite(suite);
|
||||
}
|
||||
|
||||
return suitesToReturn;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.getResults = function() {
|
||||
var results = new jasmine.NestedResults();
|
||||
for (var i = 0; i < this.suites.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user