Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix(Jasmine): add support for jasmine 2 done.fail()
Browse files Browse the repository at this point in the history
fixes #180
  • Loading branch information
vicb committed Sep 23, 2015
1 parent 0f369ab commit 1d4370b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/jasmine/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ function apply() {
var originalIt = global.it;
var originalFit = global.fit;

// Patch jasmine `done()` and `done.fail()` so that they execute in the root zone
var patchJasmineDone = function(jasmineDone) {
var done = jasmineZone.bind(jasmineDone);
if (typeof jasmineDone.fail === 'function') {
done.fail = jasmineZone.bind(jasmineDone.fail);
}

return done;
}

global.it = function zoneResettingIt(description, specFn, timeOut) {
if (specFn.length) {
originalIt(description, function zoneResettingSpecFn(originalDone) {
specFn(function zoneResettingDone() {
jasmineZone.run(originalDone);
});
originalIt(description, function zoneResettingSpecFn(done) {
specFn(patchJasmineDone(done));
}, timeOut);
} else {
originalIt(description, specFn, timeOut);
Expand All @@ -29,10 +37,8 @@ function apply() {

global.fit = function zoneResettingFit(description, specFn, timeOut) {
if (specFn.length) {
originalFit(description, function zoneResettingSpecFn(originalDone) {
specFn(function zoneResettingDone() {
jasmineZone.run(originalDone);
});
originalFit(description, function zoneResettingSpecFn(done) {
specFn(patchJasmineDone(done));
}, timeOut);
} else {
originalFit(description, specFn, timeOut);
Expand Down

0 comments on commit 1d4370b

Please sign in to comment.