JsApiReporter reports nested suites correctly.
Runner#topLevelSuites() returns only top level suites. Suite#specs(), Suite#suites(), and Suite#children() return immediate children.
This commit is contained in:
@@ -11,7 +11,7 @@ jasmine.JsApiReporter = function() {
|
||||
|
||||
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
this.started = true;
|
||||
var suites = runner.suites();
|
||||
var suites = runner.topLevelSuites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
this.suites_.push(this.summarize_(suite));
|
||||
@@ -30,10 +30,11 @@ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||
type: isSuite ? 'suite' : 'spec',
|
||||
children: []
|
||||
};
|
||||
|
||||
if (isSuite) {
|
||||
var specs = suiteOrSpec.specs();
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
summary.children.push(this.summarize_(specs[i]));
|
||||
var children = suiteOrSpec.children();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
summary.children.push(this.summarize_(children[i]));
|
||||
}
|
||||
}
|
||||
return summary;
|
||||
|
||||
@@ -58,11 +58,20 @@ jasmine.Runner.prototype.specs = function () {
|
||||
return specs;
|
||||
};
|
||||
|
||||
|
||||
jasmine.Runner.prototype.suites = function() {
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.topLevelSuites = function() {
|
||||
var topLevelSuites = [];
|
||||
for (var i = 0; i < this.suites_.length; i++) {
|
||||
if (!this.suites_[i].parentSuite) {
|
||||
topLevelSuites.push(this.suites_[i]);
|
||||
}
|
||||
}
|
||||
return topLevelSuites;
|
||||
};
|
||||
|
||||
jasmine.Runner.prototype.results = function() {
|
||||
return this.queue.results();
|
||||
};
|
||||
12
src/Suite.js
12
src/Suite.js
@@ -16,6 +16,8 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
||||
self.env = env;
|
||||
self.before_ = [];
|
||||
self.after_ = [];
|
||||
self.children_ = [];
|
||||
self.suites_ = [];
|
||||
self.specs_ = [];
|
||||
};
|
||||
|
||||
@@ -50,7 +52,9 @@ jasmine.Suite.prototype.results = function() {
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.add = function(block) {
|
||||
this.children_.push(block);
|
||||
if (block instanceof jasmine.Suite) {
|
||||
this.suites_.push(block);
|
||||
this.env.currentRunner().addSuite(block);
|
||||
} else {
|
||||
this.specs_.push(block);
|
||||
@@ -62,6 +66,14 @@ jasmine.Suite.prototype.specs = function() {
|
||||
return this.specs_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.suites = function() {
|
||||
return this.suites_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.children = function() {
|
||||
return this.children_;
|
||||
};
|
||||
|
||||
jasmine.Suite.prototype.execute = function(onComplete) {
|
||||
var self = this;
|
||||
this.queue.start(function () {
|
||||
|
||||
Reference in New Issue
Block a user