Also, dev_boot.js is now a copy of boot.js and has additional changes to load jasmine the second time, into the j$ reference.
108 lines
2.5 KiB
JavaScript
108 lines
2.5 KiB
JavaScript
getJasmineRequireObj().Suite = function() {
|
|
function Suite(attrs) {
|
|
this.env = attrs.env;
|
|
this.id = attrs.id;
|
|
this.parentSuite = attrs.parentSuite;
|
|
this.description = attrs.description;
|
|
this.onStart = attrs.onStart || function() {};
|
|
this.completeCallback = attrs.completeCallback || function() {};
|
|
this.resultCallback = attrs.resultCallback || function() {};
|
|
this.encourageGC = attrs.encourageGC || function(fn) {fn();};
|
|
|
|
this.beforeFns = [];
|
|
this.afterFns = [];
|
|
this.queueRunner = attrs.queueRunner || function() {};
|
|
this.disabled = false;
|
|
|
|
this.children_ = []; // TODO: rename
|
|
this.suites = []; // TODO: needed?
|
|
this.specs = []; // TODO: needed?
|
|
|
|
this.result = {
|
|
id: this.id,
|
|
status: this.disabled ? 'disabled' : '',
|
|
description: this.description,
|
|
fullName: this.getFullName()
|
|
};
|
|
}
|
|
|
|
Suite.prototype.getFullName = function() {
|
|
var fullName = this.description;
|
|
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
|
if (parentSuite.parentSuite) {
|
|
fullName = parentSuite.description + ' ' + fullName;
|
|
}
|
|
}
|
|
return fullName;
|
|
};
|
|
|
|
Suite.prototype.disable = function() {
|
|
this.disabled = true;
|
|
};
|
|
|
|
Suite.prototype.beforeEach = function(fn) {
|
|
this.beforeFns.unshift(fn);
|
|
};
|
|
|
|
Suite.prototype.afterEach = function(fn) {
|
|
this.afterFns.unshift(fn);
|
|
};
|
|
|
|
Suite.prototype.addSpec = function(spec) {
|
|
this.children_.push(spec);
|
|
this.specs.push(spec); // TODO: needed?
|
|
};
|
|
|
|
Suite.prototype.addSuite = function(suite) {
|
|
suite.parentSuite = this;
|
|
this.children_.push(suite);
|
|
this.suites.push(suite); // TODO: needed?
|
|
};
|
|
|
|
Suite.prototype.children = function() {
|
|
return this.children_;
|
|
};
|
|
|
|
Suite.prototype.execute = function(onComplete) {
|
|
var self = this;
|
|
if (this.disabled) {
|
|
complete();
|
|
return;
|
|
}
|
|
|
|
var allFns = [],
|
|
children = this.children_;
|
|
|
|
for (var i = 0; i < children.length; i++) {
|
|
allFns.push(wrapChild(children[i]));
|
|
}
|
|
|
|
this.onStart(this);
|
|
|
|
this.queueRunner({
|
|
fns: allFns,
|
|
onComplete: complete
|
|
});
|
|
|
|
function complete() {
|
|
self.resultCallback(self.result);
|
|
|
|
if (onComplete) {
|
|
onComplete();
|
|
}
|
|
}
|
|
|
|
function wrapChild(child) {
|
|
return function(done) {
|
|
child.execute(done);
|
|
};
|
|
}
|
|
};
|
|
|
|
return Suite;
|
|
};
|
|
|
|
if (typeof window == void 0 && typeof exports == "object") {
|
|
exports.Suite = jasmineRequire.Suite;
|
|
}
|