first (naive) pass at beforeAll/afterAll
This commit is contained in:
@@ -324,10 +324,18 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
currentSuite.beforeEach(beforeEachFunction);
|
||||
};
|
||||
|
||||
this.beforeAll = function(beforeAllFunction) {
|
||||
currentSuite.beforeAll(beforeAllFunction);
|
||||
};
|
||||
|
||||
this.afterEach = function(afterEachFunction) {
|
||||
currentSuite.afterEach(afterEachFunction);
|
||||
};
|
||||
|
||||
this.afterAll = function(afterAllFunction) {
|
||||
currentSuite.afterAll(afterAllFunction);
|
||||
};
|
||||
|
||||
this.pending = function() {
|
||||
throw j$.Spec.pendingSpecExceptionMessage;
|
||||
};
|
||||
|
||||
@@ -105,6 +105,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
};
|
||||
|
||||
Spec.prototype.isExecutable = function() {
|
||||
return !this.disabled && !this.markedPending;
|
||||
};
|
||||
|
||||
Spec.prototype.getFullName = function() {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
@@ -10,6 +10,8 @@ getJasmineRequireObj().Suite = function() {
|
||||
|
||||
this.beforeFns = [];
|
||||
this.afterFns = [];
|
||||
this.beforeAllFns = [];
|
||||
this.afterAllFns = [];
|
||||
this.queueRunner = attrs.queueRunner || function() {};
|
||||
this.disabled = false;
|
||||
|
||||
@@ -41,10 +43,18 @@ getJasmineRequireObj().Suite = function() {
|
||||
this.beforeFns.unshift(fn);
|
||||
};
|
||||
|
||||
Suite.prototype.beforeAll = function(fn) {
|
||||
this.beforeAllFns.push(fn);
|
||||
};
|
||||
|
||||
Suite.prototype.afterEach = function(fn) {
|
||||
this.afterFns.unshift(fn);
|
||||
};
|
||||
|
||||
Suite.prototype.afterAll = function(fn) {
|
||||
this.afterAllFns.push(fn);
|
||||
};
|
||||
|
||||
Suite.prototype.addChild = function(child) {
|
||||
this.children.push(child);
|
||||
};
|
||||
@@ -58,8 +68,18 @@ getJasmineRequireObj().Suite = function() {
|
||||
|
||||
var allFns = [];
|
||||
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
allFns.push(wrapChildAsAsync(this.children[i]));
|
||||
if (this.isExecutable()) {
|
||||
for (var b = 0; b < this.beforeAllFns.length; b++) {
|
||||
allFns.push(this.beforeAllFns[b]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
allFns.push(wrapChildAsAsync(this.children[i]));
|
||||
}
|
||||
|
||||
for (var a = 0; a < this.afterAllFns.length; a++) {
|
||||
allFns.push(this.afterAllFns[a]);
|
||||
}
|
||||
}
|
||||
|
||||
this.onStart(this);
|
||||
@@ -82,6 +102,17 @@ getJasmineRequireObj().Suite = function() {
|
||||
}
|
||||
};
|
||||
|
||||
Suite.prototype.isExecutable = function() {
|
||||
var foundActive = false;
|
||||
for(var i = 0; i < this.children.length; i++) {
|
||||
if(this.children[i].isExecutable()) {
|
||||
foundActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return foundActive;
|
||||
};
|
||||
|
||||
return Suite;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user