This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jasmine): export the jasmine patch
- Loading branch information
Showing
10 changed files
with
143 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var jasminePatch = require('../jasmine/patch'); | ||
|
||
jasminePatch.apply(); | ||
|
||
},{"../jasmine/patch":2}],2:[function(require,module,exports){ | ||
(function (global){ | ||
'use strict'; | ||
// Patch jasmine's it and fit functions so that the `done` callback always resets the zone | ||
// to the jasmine zone, which should be the root zone. (angular/zone.js#91) | ||
|
||
function apply() { | ||
if (!global.zone) { | ||
throw new Error('zone.js does not seem to be installed'); | ||
} | ||
|
||
if (!global.zone.isRootZone()) { | ||
throw new Error('The jasmine patch should be called from the root zone'); | ||
} | ||
|
||
var jasmineZone = global.zone; | ||
var originalIt = global.it; | ||
var originalFit = global.fit; | ||
|
||
global.it = function zoneResettingIt(description, specFn) { | ||
if (specFn.length) { | ||
originalIt(description, function zoneResettingSpecFn(originalDone) { | ||
specFn(function zoneResettingDone() { | ||
jasmineZone.run(originalDone); | ||
}); | ||
}); | ||
} else { | ||
originalIt(description, specFn); | ||
} | ||
}; | ||
|
||
global.fit = function zoneResettingFit(description, specFn) { | ||
if (specFn.length) { | ||
originalFit(description, function zoneResettingSpecFn(originalDone) { | ||
specFn(function zoneResettingDone() { | ||
jasmineZone.run(originalDone); | ||
}); | ||
}); | ||
} else { | ||
originalFit(description, specFn); | ||
} | ||
}; | ||
|
||
// global beforeEach to check if we always start from the root zone | ||
beforeEach(function() { | ||
expect(global.zone.isRootZone()).toBe(true); | ||
}); | ||
} | ||
|
||
if (global.jasmine) { | ||
module.exports = { | ||
apply: apply | ||
}; | ||
} else { | ||
module.exports = { | ||
apply: function() { } | ||
}; | ||
} | ||
|
||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}]},{},[1]); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var jasminePatch = require('../jasmine/patch'); | ||
|
||
jasminePatch.apply(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
// Patch jasmine's it and fit functions so that the `done` callback always resets the zone | ||
// to the jasmine zone, which should be the root zone. (angular/zone.js#91) | ||
|
||
function apply() { | ||
if (!global.zone) { | ||
throw new Error('zone.js does not seem to be installed'); | ||
} | ||
|
||
if (!global.zone.isRootZone()) { | ||
throw new Error('The jasmine patch should be called from the root zone'); | ||
} | ||
|
||
var jasmineZone = global.zone; | ||
var originalIt = global.it; | ||
var originalFit = global.fit; | ||
|
||
global.it = function zoneResettingIt(description, specFn) { | ||
if (specFn.length) { | ||
originalIt(description, function zoneResettingSpecFn(originalDone) { | ||
specFn(function zoneResettingDone() { | ||
jasmineZone.run(originalDone); | ||
}); | ||
}); | ||
} else { | ||
originalIt(description, specFn); | ||
} | ||
}; | ||
|
||
global.fit = function zoneResettingFit(description, specFn) { | ||
if (specFn.length) { | ||
originalFit(description, function zoneResettingSpecFn(originalDone) { | ||
specFn(function zoneResettingDone() { | ||
jasmineZone.run(originalDone); | ||
}); | ||
}); | ||
} else { | ||
originalFit(description, specFn); | ||
} | ||
}; | ||
|
||
// global beforeEach to check if we always start from the root zone | ||
beforeEach(function() { | ||
expect(global.zone.isRootZone()).toBe(true); | ||
}); | ||
} | ||
|
||
if (global.jasmine) { | ||
module.exports = { | ||
apply: apply | ||
}; | ||
} else { | ||
module.exports = { | ||
apply: function() { } | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
// Setup tests for Zone with microtask support | ||
require('../lib/browser/zone-microtask.js'); | ||
|
||
// Patch jasmine | ||
require('../lib/browser/jasmine-patch.js'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
// Setup tests for Zone without microtask support | ||
require('../lib/browser/zone.js'); | ||
|
||
// Patch jasmine | ||
require('../lib/browser/jasmine-patch.js'); | ||
|