1 /** 2 * For storing & executing a Jasmine suite. 3 * 4 * @constructor 5 * @param {jasmine.Env} env 6 * @param {String} description 7 * @param {Function} specDefinitions 8 * @param {jasmine.Suite} parentSuite 9 */ 10 jasmine.Suite = function(env, description, specDefinitions, parentSuite) { 11 jasmine.ActionCollection.call(this, env); 12 13 this.description = description; 14 this.specs = this.actions; 15 this.parentSuite = parentSuite; 16 17 this.beforeEachFunction = null; 18 this.afterEachFunction = null; 19 }; 20 jasmine.util.inherit(jasmine.Suite, jasmine.ActionCollection); 21 22 jasmine.Suite.prototype.getFullName = function() { 23 var fullName = this.description; 24 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { 25 fullName = parentSuite.description + ' ' + fullName; 26 } 27 return fullName; 28 }; 29 30 jasmine.Suite.prototype.finishCallback = function() { 31 if (this.env.reporter) { 32 this.env.reporter.reportSuiteResults(this); 33 } 34 }; 35 36 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { 37 beforeEachFunction.typeName = 'beforeEach'; 38 this.beforeEachFunction = beforeEachFunction; 39 }; 40 41 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { 42 afterEachFunction.typeName = 'afterEach'; 43 this.afterEachFunction = afterEachFunction; 44 }; 45 46 jasmine.Suite.prototype.getResults = function() { 47 var results = new jasmine.NestedResults(); 48 for (var i = 0; i < this.specs.length; i++) { 49 results.rollupCounts(this.specs[i].getResults()); 50 } 51 return results; 52 }; 53 54