dwf/cj: added function and tests to get a suite's spec count
This commit is contained in:
parent
7edeb13be8
commit
187bde37ca
@ -1743,7 +1743,7 @@ jasmine.Spec.prototype.removeAllSpies = function() {
|
|||||||
* @param {jasmine.Suite} parentSuite
|
* @param {jasmine.Suite} parentSuite
|
||||||
*/
|
*/
|
||||||
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.id = env.nextSuiteId_++;
|
self.id = env.nextSuiteId_++;
|
||||||
self.description = description;
|
self.description = description;
|
||||||
self.queue = new jasmine.Queue(env);
|
self.queue = new jasmine.Queue(env);
|
||||||
@ -1754,7 +1754,6 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
|||||||
self.specs = [];
|
self.specs = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
jasmine.Suite.prototype.getFullName = function() {
|
jasmine.Suite.prototype.getFullName = function() {
|
||||||
var fullName = this.description;
|
var fullName = this.description;
|
||||||
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||||
@ -1787,17 +1786,22 @@ jasmine.Suite.prototype.getResults = function() {
|
|||||||
|
|
||||||
jasmine.Suite.prototype.add = function(block) {
|
jasmine.Suite.prototype.add = function(block) {
|
||||||
if (block instanceof jasmine.Suite) {
|
if (block instanceof jasmine.Suite) {
|
||||||
this.env.currentRunner.addSuite(block);
|
this.env.currentRunner.addSuite(block);
|
||||||
}
|
}
|
||||||
this.specs.push(block);
|
this.specs.push(block);
|
||||||
this.queue.add(block);
|
this.queue.add(block);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Suite.prototype.execute = function(onComplete) {
|
jasmine.Suite.prototype.specCount = function(block) {
|
||||||
var self = this;
|
return this.specs.length;
|
||||||
this.queue.start(function () { self.finish(onComplete); });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jasmine.Suite.prototype.execute = function(onComplete) {
|
||||||
|
var self = this;
|
||||||
|
this.queue.start(function () {
|
||||||
|
self.finish(onComplete);
|
||||||
|
});
|
||||||
|
};
|
||||||
jasmine.WaitsBlock = function(env, timeout, spec) {
|
jasmine.WaitsBlock = function(env, timeout, spec) {
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
jasmine.Block.call(this, env, null, spec);
|
jasmine.Block.call(this, env, null, spec);
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
jasmine.include('suites/RunnerSpec.js', true);
|
jasmine.include('suites/RunnerSpec.js', true);
|
||||||
jasmine.include('suites/SpecRunningSpec.js', true);
|
jasmine.include('suites/SpecRunningSpec.js', true);
|
||||||
jasmine.include('suites/SpySpec.js', true);
|
jasmine.include('suites/SpySpec.js', true);
|
||||||
|
jasmine.include('suites/SuiteSpec.js', true);
|
||||||
jasmine.include('suites/TrivialReporterSpec.js', true);
|
jasmine.include('suites/TrivialReporterSpec.js', true);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
65
spec/suites/SuiteSpec.js
Normal file
65
spec/suites/SuiteSpec.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
describe('Suite', function() {
|
||||||
|
var fakeTimer;
|
||||||
|
var env;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
env = new jasmine.Env();
|
||||||
|
|
||||||
|
fakeTimer = new jasmine.FakeTimer();
|
||||||
|
env.setTimeout = fakeTimer.setTimeout;
|
||||||
|
env.clearTimeout = fakeTimer.clearTimeout;
|
||||||
|
env.setInterval = fakeTimer.setInterval;
|
||||||
|
env.clearInterval = fakeTimer.clearInterval;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should keep a count of the number of specs that are run' , function() {
|
||||||
|
env.describe('one suite description', function () {
|
||||||
|
env.it('should be a test', function() {
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
env.it('should be another test', function() {
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
env.it('should be a third test', function() {
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var suite = env.currentRunner.suites[0];
|
||||||
|
expect(suite.specCount()).toEqual(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('specCount should be correct even with runs/waits blocks' , function() {
|
||||||
|
env.describe('one suite description', function () {
|
||||||
|
env.it('should be a test', function() {
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
env.it('should be another test', function() {
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
this.waits(10);
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
env.it('should be a third test', function() {
|
||||||
|
this.runs(function () {
|
||||||
|
this.expect(true).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var suite = env.currentRunner.suites[0];
|
||||||
|
expect(suite.specCount()).toEqual(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
18
src/Suite.js
18
src/Suite.js
@ -8,7 +8,7 @@
|
|||||||
* @param {jasmine.Suite} parentSuite
|
* @param {jasmine.Suite} parentSuite
|
||||||
*/
|
*/
|
||||||
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.id = env.nextSuiteId_++;
|
self.id = env.nextSuiteId_++;
|
||||||
self.description = description;
|
self.description = description;
|
||||||
self.queue = new jasmine.Queue(env);
|
self.queue = new jasmine.Queue(env);
|
||||||
@ -19,7 +19,6 @@ jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
|||||||
self.specs = [];
|
self.specs = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
jasmine.Suite.prototype.getFullName = function() {
|
jasmine.Suite.prototype.getFullName = function() {
|
||||||
var fullName = this.description;
|
var fullName = this.description;
|
||||||
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||||
@ -52,14 +51,19 @@ jasmine.Suite.prototype.getResults = function() {
|
|||||||
|
|
||||||
jasmine.Suite.prototype.add = function(block) {
|
jasmine.Suite.prototype.add = function(block) {
|
||||||
if (block instanceof jasmine.Suite) {
|
if (block instanceof jasmine.Suite) {
|
||||||
this.env.currentRunner.addSuite(block);
|
this.env.currentRunner.addSuite(block);
|
||||||
}
|
}
|
||||||
this.specs.push(block);
|
this.specs.push(block);
|
||||||
this.queue.add(block);
|
this.queue.add(block);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Suite.prototype.execute = function(onComplete) {
|
jasmine.Suite.prototype.specCount = function(block) {
|
||||||
var self = this;
|
return this.specs.length;
|
||||||
this.queue.start(function () { self.finish(onComplete); });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jasmine.Suite.prototype.execute = function(onComplete) {
|
||||||
|
var self = this;
|
||||||
|
this.queue.start(function () {
|
||||||
|
self.finish(onComplete);
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user