beforeAll can have expectations and passes expectation failures to its children

[#66789174]
This commit is contained in:
Christopher Amavisca and Greg Cobb
2014-03-05 16:27:58 -08:00
parent a9e0112a9b
commit a3c3505086
6 changed files with 82 additions and 3 deletions

View File

@@ -79,6 +79,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return env.afterEach(afterEachFunction);
},
beforeAll: function(beforeAllFunction) {
return env.beforeAll(beforeAllFunction);
},
afterAll: function(afterAllFunction) {
return env.afterAll(afterAllFunction);
},
expect: function(actual) {
return env.expect(actual);
},

View File

@@ -57,6 +57,14 @@
return env.afterEach(afterEachFunction);
},
beforeAll: function(beforeAllFunction) {
return env.beforeAll(beforeAllFunction);
},
afterAll: function(afterAllFunction) {
return env.afterAll(afterAllFunction);
},
expect: function(actual) {
return env.expect(actual);
},

View File

@@ -599,6 +599,7 @@ getJasmineRequireObj().Env = function(j$) {
parentSuite: currentDeclarationSuite,
queueRunner: queueRunnerFactory,
onStart: suiteStarted,
expectationFactory: expectationFactory,
resultCallback: function(attrs) {
if (!suite.disabled) {
clearResourcesForRunnable(suite.id);
@@ -704,7 +705,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.expect = function(actual) {
return currentSpec.expect(actual);
return currentRunnable().expect(actual);
};
this.beforeEach = function(beforeEachFunction) {
@@ -1795,6 +1796,7 @@ getJasmineRequireObj().Suite = function() {
this.onStart = attrs.onStart || function() {};
this.resultCallback = attrs.resultCallback || function() {};
this.clearStack = attrs.clearStack || function(fn) {fn();};
this.expectationFactory = attrs.expectationFactory;
this.beforeFns = [];
this.afterFns = [];
@@ -1813,6 +1815,10 @@ getJasmineRequireObj().Suite = function() {
};
}
Suite.prototype.expect = function(actual) {
return this.expectationFactory(actual, this);
};
Suite.prototype.getFullName = function() {
var fullName = this.description;
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
@@ -1918,6 +1924,13 @@ getJasmineRequireObj().Suite = function() {
}
};
Suite.prototype.addExpectationResult = function () {
for (var i = 0; i < this.children.length; i++) {
var child = this.children[i];
child.addExpectationResult.apply(child, arguments);
}
};
function clone(obj) {
var clonedObj = {};
for (var prop in obj) {