2009-05-29 03:02:15 +00:00
|
|
|
/**
|
2009-07-09 00:55:25 +00:00
|
|
|
* Internal representation of a Jasmine suite.
|
2009-05-29 03:02:15 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {jasmine.Env} env
|
|
|
|
* @param {String} description
|
|
|
|
* @param {Function} specDefinitions
|
|
|
|
* @param {jasmine.Suite} parentSuite
|
|
|
|
*/
|
|
|
|
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
|
2009-08-01 22:28:39 +00:00
|
|
|
var self = this;
|
|
|
|
self.id = env.nextSuiteId_++;
|
|
|
|
self.description = description;
|
2009-08-13 14:52:44 +00:00
|
|
|
self.queue = new jasmine.Queue(env);
|
2009-08-01 22:28:39 +00:00
|
|
|
self.parentSuite = parentSuite;
|
|
|
|
self.env = env;
|
|
|
|
self.beforeQueue = [];
|
|
|
|
self.afterQueue = [];
|
2009-08-26 22:55:08 +00:00
|
|
|
self.specs = [];
|
2009-05-29 03:02:15 +00:00
|
|
|
};
|
2009-08-01 22:28:39 +00:00
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
|
|
|
|
jasmine.Suite.prototype.getFullName = function() {
|
|
|
|
var fullName = this.description;
|
|
|
|
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
|
|
|
fullName = parentSuite.description + ' ' + fullName;
|
|
|
|
}
|
|
|
|
return fullName;
|
|
|
|
};
|
|
|
|
|
2009-08-04 05:22:13 +00:00
|
|
|
jasmine.Suite.prototype.finish = function(onComplete) {
|
2009-07-09 01:01:05 +00:00
|
|
|
this.env.reporter.reportSuiteResults(this);
|
2009-08-01 22:28:39 +00:00
|
|
|
this.finished = true;
|
2009-08-04 05:22:13 +00:00
|
|
|
if (typeof(onComplete) == 'function') {
|
|
|
|
onComplete();
|
2009-08-01 22:28:39 +00:00
|
|
|
}
|
2009-05-29 03:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
|
|
|
|
beforeEachFunction.typeName = 'beforeEach';
|
2009-08-01 17:43:03 +00:00
|
|
|
this.beforeQueue.push(beforeEachFunction);
|
2009-05-29 03:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
|
|
|
afterEachFunction.typeName = 'afterEach';
|
2009-08-01 17:43:03 +00:00
|
|
|
this.afterQueue.push(afterEachFunction);
|
2009-05-29 03:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
jasmine.Suite.prototype.getResults = function() {
|
2009-08-01 22:28:39 +00:00
|
|
|
return this.queue.getResults();
|
|
|
|
};
|
|
|
|
|
|
|
|
jasmine.Suite.prototype.add = function(block) {
|
2009-08-19 14:42:47 +00:00
|
|
|
if (block instanceof jasmine.Suite) {
|
|
|
|
this.env.currentRunner.addSuite(block);
|
|
|
|
}
|
2009-08-26 22:55:08 +00:00
|
|
|
this.specs.push(block);
|
2009-08-01 22:28:39 +00:00
|
|
|
this.queue.add(block);
|
2009-05-29 03:02:15 +00:00
|
|
|
};
|
|
|
|
|
2009-08-04 05:22:13 +00:00
|
|
|
jasmine.Suite.prototype.execute = function(onComplete) {
|
|
|
|
var self = this;
|
|
|
|
this.queue.start(function () { self.finish(onComplete); });
|
2009-08-01 22:28:39 +00:00
|
|
|
};
|
|
|
|
|