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

Commit

Permalink
chare: release v0.8.26
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Apr 8, 2018
1 parent b3fdd7e commit 1ba8519
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 144 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="0.8.26"></a>
## [0.8.26](https://github.com/angular/zone.js/compare/v0.8.25...0.8.26) (2018-04-08)


### Bug Fixes

* **test:** fix [#1069](https://github.com/angular/zone.js/issues/1069), FakeDate should handle constructor parameter ([#1070](https://github.com/angular/zone.js/issues/1070)) ([b3fdd7e](https://github.com/angular/zone.js/commit/b3fdd7e))



<a name="0.8.25"></a>
## [0.8.25](https://github.com/angular/zone.js/compare/v0.8.24...0.8.25) (2018-04-04)

Expand Down
63 changes: 53 additions & 10 deletions dist/fake-async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,58 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
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) {
var OriginalDate = global.Date;
var FakeDate = /** @class */ (function () {
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 () {
var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
if (fakeAsyncTestZoneSpec) {
return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime();
}
return OriginalDate.now.apply(this, arguments);
};
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 () {
function Scheduler() {
// Next scheduler id.
Expand All @@ -50,7 +79,7 @@
// Current simulated time in millis.
this._currentTime = 0;
// Current real time in millis.
this._currentRealTime = Date.now();
this._currentRealTime = OriginalDate.now();
}
Scheduler.prototype.getCurrentTime = function () {
return this._currentTime;
Expand Down Expand Up @@ -309,12 +338,26 @@
}
global['Date'] = FakeDate;
FakeDate.prototype = OriginalDate.prototype;
// try check and reset timers
// because jasmine.clock().install() may
// have replaced the global timer
FakeAsyncTestZoneSpec.checkTimerPatch();
};
FakeAsyncTestZoneSpec.resetDate = function () {
if (global['Date'] === FakeDate) {
global['Date'] = OriginalDate;
}
};
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 () {
this.patchDateLocked = true;
FakeAsyncTestZoneSpec.patchDate();
Expand Down
52 changes: 29 additions & 23 deletions dist/jasmine-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,48 @@
return originalJasmineFn.apply(this, arguments);
};
});
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 () {
var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
if (fakeAsyncZoneSpec) {
return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments);
}
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;
};
/**
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a
* synchronous-only zone.
Expand Down
2 changes: 1 addition & 1 deletion dist/jasmine-patch.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 29 additions & 9 deletions dist/zone-patch-resize-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
(factory());
}(this, (function () { 'use strict';

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 };
}
};
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
Expand All @@ -31,17 +41,26 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) {
var _this = this;
var zones = {};
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; }
}
Object.keys(zones).forEach(function (zoneName) {
var zoneEntriesInfo = zones[zoneName];
Expand All @@ -52,6 +71,7 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) {
callback.call(_this, zoneEntriesInfo.entries, observer);
}
});
var e_1, _a;
};
}
return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver();
Expand Down
Loading

0 comments on commit 1ba8519

Please sign in to comment.