Comparing version 0.8.25 to 0.8.26
@@ -21,2 +21,22 @@ /** | ||
*/ | ||
var __read = (undefined && undefined.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spread = (undefined && undefined.__spread) || function () { | ||
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
}; | ||
(function (global) { | ||
@@ -26,9 +46,12 @@ var OriginalDate = global.Date; | ||
function FakeDate() { | ||
var d = new OriginalDate(); | ||
d.setTime(global.Date.now()); | ||
return d; | ||
if (arguments.length === 0) { | ||
var d = new OriginalDate(); | ||
d.setTime(FakeDate.now()); | ||
return d; | ||
} | ||
else { | ||
var args = Array.prototype.slice.call(arguments); | ||
return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); | ||
} | ||
} | ||
FakeDate.UTC = function () { | ||
return OriginalDate.UTC(); | ||
}; | ||
FakeDate.now = function () { | ||
@@ -41,7 +64,13 @@ var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); | ||
}; | ||
FakeDate.parse = function () { | ||
return OriginalDate.parse(); | ||
}; | ||
return FakeDate; | ||
}()); | ||
FakeDate.UTC = OriginalDate.UTC; | ||
FakeDate.parse = OriginalDate.parse; | ||
// keep a reference for zone patched timer function | ||
var timers = { | ||
setTimeout: global.setTimeout, | ||
setInterval: global.setInterval, | ||
clearTimeout: global.clearTimeout, | ||
clearInterval: global.clearInterval | ||
}; | ||
var Scheduler = /** @class */ (function () { | ||
@@ -56,3 +85,3 @@ function Scheduler() { | ||
// Current real time in millis. | ||
this._currentRealTime = Date.now(); | ||
this._currentRealTime = OriginalDate.now(); | ||
} | ||
@@ -316,2 +345,6 @@ Scheduler.prototype.getCurrentTime = function () { | ||
FakeDate.prototype = OriginalDate.prototype; | ||
// try check and reset timers | ||
// because jasmine.clock().install() may | ||
// have replaced the global timer | ||
FakeAsyncTestZoneSpec.checkTimerPatch(); | ||
}; | ||
@@ -323,2 +356,12 @@ FakeAsyncTestZoneSpec.resetDate = function () { | ||
}; | ||
FakeAsyncTestZoneSpec.checkTimerPatch = function () { | ||
if (global.setTimeout !== timers.setTimeout) { | ||
global.setTimeout = timers.setTimeout; | ||
global.clearTimeout = timers.clearTimeout; | ||
} | ||
if (global.setInterval !== timers.setInterval) { | ||
global.setInterval = timers.setInterval; | ||
global.clearInterval = timers.clearInterval; | ||
} | ||
}; | ||
FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { | ||
@@ -325,0 +368,0 @@ this.patchDateLocked = true; |
@@ -79,7 +79,10 @@ /** | ||
}); | ||
if (enableClockPatch) { | ||
var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); | ||
jasmine['clock'] = function () { | ||
var clock = originalClockFn_1.apply(this, arguments); | ||
var originalTick = (clock[symbol('tick')] = clock.tick); | ||
// need to patch jasmine.clock().mockDate and jasmine.clock().tick() so | ||
// they can work properly in FakeAsyncTest | ||
var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); | ||
jasmine['clock'] = function () { | ||
var clock = originalClockFn.apply(this, arguments); | ||
if (!clock[symbol('patched')]) { | ||
clock[symbol('patched')] = symbol('patched'); | ||
var originalTick_1 = (clock[symbol('tick')] = clock.tick); | ||
clock.tick = function () { | ||
@@ -90,28 +93,31 @@ var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); | ||
} | ||
return originalTick.apply(this, arguments); | ||
return originalTick_1.apply(this, arguments); | ||
}; | ||
var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); | ||
var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); | ||
clock.mockDate = function () { | ||
var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); | ||
if (fakeAsyncZoneSpec) { | ||
var dateTime = arguments[0]; | ||
var dateTime = arguments.length > 0 ? arguments[0] : new Date(); | ||
return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : | ||
arguments); | ||
} | ||
return originalMockDate.apply(this, arguments); | ||
return originalMockDate_1.apply(this, arguments); | ||
}; | ||
['install', 'uninstall'].forEach(function (methodName) { | ||
var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); | ||
clock[methodName] = function () { | ||
var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; | ||
if (FakeAsyncTestZoneSpec) { | ||
jasmine[symbol('clockInstalled')] = 'install' === methodName; | ||
return; | ||
} | ||
return originalClockFn.apply(this, arguments); | ||
}; | ||
}); | ||
return clock; | ||
}; | ||
} | ||
// for auto go into fakeAsync feature, we need the flag to enable it | ||
if (enableClockPatch) { | ||
['install', 'uninstall'].forEach(function (methodName) { | ||
var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); | ||
clock[methodName] = function () { | ||
var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; | ||
if (FakeAsyncTestZoneSpec) { | ||
jasmine[symbol('clockInstalled')] = 'install' === methodName; | ||
return; | ||
} | ||
return originalClockFn.apply(this, arguments); | ||
}; | ||
}); | ||
} | ||
} | ||
return clock; | ||
}; | ||
/** | ||
@@ -118,0 +124,0 @@ * Gets a function wrapping the body of a Jasmine `describe` block to execute in a |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return u.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[a("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var s=Zone[Zone.__symbol__("fakeAsyncTest")];s&&"function"==typeof s.fakeAsync&&(e=s.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;if(!Zone)throw new Error("Missing: zone.js");if("undefined"==typeof jasmine)throw new Error("Missing: jasmine.js");if(jasmine.__zone_patch__)throw new Error("'jasmine' has already been patched with 'Zone'.");jasmine.__zone_patch__=!0;var i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,u=c.fork(new i("jasmine.describe")),a=Zone.__symbol__,f=r[a("fakeAsyncPatchLock")]===!0,l=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(function(n){var t=l[n];l[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=l[e];l[a(e)]=n,l[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=l[e];l[a(e)]=n,l[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}}),f){var p=jasmine[a("clock")]=jasmine.clock;jasmine.clock=function(){var e=p.apply(this,arguments),n=e[a("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[a("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[a(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[a("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e}}var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return a.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[u("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;if(!Zone)throw new Error("Missing: zone.js");if("undefined"==typeof jasmine)throw new Error("Missing: jasmine.js");if(jasmine.__zone_patch__)throw new Error("'jasmine' has already been patched with 'Zone'.");jasmine.__zone_patch__=!0;var i=Zone.SyncTestZoneSpec,c=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!c)throw new Error("Missing: ProxyZoneSpec");var s=Zone.current,a=s.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=r[u("fakeAsyncPatchLock")]===!0,p=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=p[n];p[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=p[e];p[u(e)]=n,p[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=p[e];p[u(e)]=n,p[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments);if(!e[u("patched")]){e[u("patched")]=u("patched");var n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},f&&["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}})}return e};var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,s.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}c&&c.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===s){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new c,this.testProxyZone=s.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); |
@@ -14,2 +14,12 @@ /** | ||
var __values = (undefined && undefined.__values) || function (o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
}; | ||
/** | ||
@@ -35,13 +45,22 @@ * @license | ||
var currZone = Zone.current; | ||
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { | ||
var entry = entries_1[_i]; | ||
var zone = entry.target[resizeObserverSymbol]; | ||
if (!zone) { | ||
zone = currZone; | ||
try { | ||
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { | ||
var entry = entries_1_1.value; | ||
var zone = entry.target[resizeObserverSymbol]; | ||
if (!zone) { | ||
zone = currZone; | ||
} | ||
var zoneEntriesInfo = zones[zone.name]; | ||
if (!zoneEntriesInfo) { | ||
zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; | ||
} | ||
zoneEntriesInfo.entries.push(entry); | ||
} | ||
var zoneEntriesInfo = zones[zone.name]; | ||
if (!zoneEntriesInfo) { | ||
zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); | ||
} | ||
zoneEntriesInfo.entries.push(entry); | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
@@ -57,2 +76,3 @@ Object.keys(zones).forEach(function (zoneName) { | ||
}); | ||
var e_1, _a; | ||
}; | ||
@@ -59,0 +79,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("ResizeObserver",function(e,n,r){var t=e.ResizeObserver;if(t){var o=r.symbol("ResizeObserver");r.patchMethod(e,"ResizeObserver",function(e){return function(e,r){var i=r.length>0?r[0]:null;return i&&(r[0]=function(e,r){for(var t=this,u={},a=n.current,c=0,f=e;c<f.length;c++){var p=f[c],s=p.target[o];s||(s=a);var l=u[s.name];l||(u[s.name]=l={entries:[],zone:s}),l.entries.push(p)}Object.keys(u).forEach(function(e){var o=u[e];o.zone!==n.current?o.zone.run(i,t,[o.entries,r],"ResizeObserver"):i.call(t,o.entries,r)})}),r.length>0?new t(r[0]):new t}}),r.patchMethod(t.prototype,"observe",function(e){return function(r,t){var i=t.length>0?t[0]:null;if(!i)return e.apply(r,t);var u=r[o];return u||(u=r[o]=[]),u.push(i),i[o]=n.current,e.apply(r,t)}}),r.patchMethod(t.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var i=n[o];if(i)for(var u=0;u<i.length;u++)if(i[u]===t){i.splice(u,1);break}return t[o]=void 0,e.apply(n,r)}}),r.patchMethod(t.prototype,"disconnect",function(e){return function(n,r){var t=n[o];return t&&(t.forEach(function(e){e[o]=void 0}),n[o]=void 0),e.apply(n,r)}})}})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";var e=function(e){var n="function"==typeof Symbol&&e[Symbol.iterator],r=0;return n?n.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o=this,a={},c=r.current;try{for(var f=e(n),l=f.next();!l.done;l=f.next()){var v=l.value,p=v.target[i];p||(p=c);var s=a[p.name];s||(a[p.name]=s={entries:[],zone:p}),s.entries.push(v)}}catch(h){d={error:h}}finally{try{l&&!l.done&&(y=f["return"])&&y.call(f)}finally{if(d)throw d.error}}Object.keys(a).forEach(function(e){var n=a[e];n.zone!==r.current?n.zone.run(u,o,[n.entries,t],"ResizeObserver"):u.call(o,n.entries,t)});var d,y}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u<o.length;u++)if(o[u]===t){o.splice(u,1);break}return t[i]=void 0,e.apply(n,r)}}),t.patchMethod(o.prototype,"disconnect",function(e){return function(n,r){var t=n[i];return t&&(t.forEach(function(e){e[i]=void 0}),n[i]=void 0),e.apply(n,r)}})}})}); |
@@ -70,6 +70,10 @@ /** | ||
}); | ||
if (enableClockPatch) { | ||
const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); | ||
(jasmine as any)['clock'] = function() { | ||
const clock = originalClockFn.apply(this, arguments); | ||
// need to patch jasmine.clock().mockDate and jasmine.clock().tick() so | ||
// they can work properly in FakeAsyncTest | ||
const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); | ||
(jasmine as any)['clock'] = function() { | ||
const clock = originalClockFn.apply(this, arguments); | ||
if (!clock[symbol('patched')]) { | ||
clock[symbol('patched')] = symbol('patched'); | ||
const originalTick = (clock[symbol('tick')] = clock.tick); | ||
@@ -87,3 +91,3 @@ clock.tick = function() { | ||
if (fakeAsyncZoneSpec) { | ||
const dateTime = arguments[0]; | ||
const dateTime = arguments.length > 0 ? arguments[0] : new Date(); | ||
return fakeAsyncZoneSpec.setCurrentRealTime.apply( | ||
@@ -96,16 +100,19 @@ fakeAsyncZoneSpec, | ||
}; | ||
['install', 'uninstall'].forEach(methodName => { | ||
const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); | ||
clock[methodName] = function() { | ||
const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; | ||
if (FakeAsyncTestZoneSpec) { | ||
(jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; | ||
return; | ||
} | ||
return originalClockFn.apply(this, arguments); | ||
}; | ||
}); | ||
return clock; | ||
}; | ||
} | ||
// for auto go into fakeAsync feature, we need the flag to enable it | ||
if (enableClockPatch) { | ||
['install', 'uninstall'].forEach(methodName => { | ||
const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); | ||
clock[methodName] = function() { | ||
const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; | ||
if (FakeAsyncTestZoneSpec) { | ||
(jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; | ||
return; | ||
} | ||
return originalClockFn.apply(this, arguments); | ||
}; | ||
}); | ||
} | ||
} | ||
return clock; | ||
}; | ||
@@ -112,0 +119,0 @@ /** |
@@ -35,11 +35,12 @@ /** | ||
constructor() { | ||
const d = new OriginalDate(); | ||
d.setTime(global.Date.now()); | ||
return d; | ||
if (arguments.length === 0) { | ||
const d = new OriginalDate(); | ||
d.setTime(FakeDate.now()); | ||
return d; | ||
} else { | ||
const args = Array.prototype.slice.call(arguments); | ||
return new OriginalDate(...args); | ||
} | ||
} | ||
static UTC() { | ||
return OriginalDate.UTC(); | ||
} | ||
static now() { | ||
@@ -52,8 +53,15 @@ const fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); | ||
} | ||
static parse() { | ||
return OriginalDate.parse(); | ||
} | ||
} | ||
(FakeDate as any).UTC = OriginalDate.UTC; | ||
(FakeDate as any).parse = OriginalDate.parse; | ||
// keep a reference for zone patched timer function | ||
const timers = { | ||
setTimeout: global.setTimeout, | ||
setInterval: global.setInterval, | ||
clearTimeout: global.clearTimeout, | ||
clearInterval: global.clearInterval | ||
}; | ||
class Scheduler { | ||
@@ -68,3 +76,3 @@ // Next scheduler id. | ||
// Current real time in millis. | ||
private _currentRealTime: number = Date.now(); | ||
private _currentRealTime: number = OriginalDate.now(); | ||
@@ -347,2 +355,7 @@ constructor() {} | ||
FakeDate.prototype = OriginalDate.prototype; | ||
// try check and reset timers | ||
// because jasmine.clock().install() may | ||
// have replaced the global timer | ||
FakeAsyncTestZoneSpec.checkTimerPatch(); | ||
} | ||
@@ -356,2 +369,13 @@ | ||
static checkTimerPatch() { | ||
if (global.setTimeout !== timers.setTimeout) { | ||
global.setTimeout = timers.setTimeout; | ||
global.clearTimeout = timers.clearTimeout; | ||
} | ||
if (global.setInterval !== timers.setInterval) { | ||
global.setInterval = timers.setInterval; | ||
global.clearInterval = timers.clearInterval; | ||
} | ||
} | ||
lockDatePatch() { | ||
@@ -358,0 +382,0 @@ this.patchDateLocked = true; |
{ | ||
"name": "zone.js", | ||
"version": "0.8.25", | ||
"version": "0.8.26", | ||
"description": "Zones for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/zone-node.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1417650
30420