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

Commit 262d13a

Browse files
authored
chore: release v0.6.24 (#459)
1 parent 8dd06e5 commit 262d13a

17 files changed

+871
-689
lines changed

dist/async-test.js

Lines changed: 80 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,81 @@
1-
(function () {
2-
var AsyncTestZoneSpec = (function () {
3-
function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) {
4-
this._pendingMicroTasks = false;
5-
this._pendingMacroTasks = false;
6-
this._alreadyErrored = false;
7-
this.runZone = Zone.current;
8-
this._finishCallback = finishCallback;
9-
this._failCallback = failCallback;
10-
this.name = 'asyncTestZone for ' + namePrefix;
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
(function (global, factory) {
9+
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
10+
typeof define === 'function' && define.amd ? define(factory) :
11+
(factory());
12+
}(this, (function () { 'use strict';
13+
14+
var AsyncTestZoneSpec = (function () {
15+
function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) {
16+
this._pendingMicroTasks = false;
17+
this._pendingMacroTasks = false;
18+
this._alreadyErrored = false;
19+
this.runZone = Zone.current;
20+
this._finishCallback = finishCallback;
21+
this._failCallback = failCallback;
22+
this.name = 'asyncTestZone for ' + namePrefix;
23+
}
24+
AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () {
25+
var _this = this;
26+
if (!(this._pendingMicroTasks || this._pendingMacroTasks)) {
27+
// We do this because we would like to catch unhandled rejected promises.
28+
this.runZone.run(function () {
29+
setTimeout(function () {
30+
if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) {
31+
_this._finishCallback();
32+
}
33+
}, 0);
34+
});
1135
}
12-
AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () {
13-
var _this = this;
14-
if (!(this._pendingMicroTasks || this._pendingMacroTasks)) {
15-
// We do this because we would like to catch unhandled rejected promises.
16-
this.runZone.run(function () {
17-
setTimeout(function () {
18-
if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) {
19-
_this._finishCallback();
20-
}
21-
}, 0);
22-
});
23-
}
24-
};
25-
// Note - we need to use onInvoke at the moment to call finish when a test is
26-
// fully synchronous. TODO(juliemr): remove this when the logic for
27-
// onHasTask changes and it calls whenever the task queues are dirty.
28-
AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) {
29-
try {
30-
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);
31-
}
32-
finally {
33-
this._finishCallbackIfDone();
34-
}
35-
};
36-
AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
37-
// Let the parent try to handle the error.
38-
var result = parentZoneDelegate.handleError(targetZone, error);
39-
if (result) {
40-
this._failCallback(error);
41-
this._alreadyErrored = true;
42-
}
43-
return false;
44-
};
45-
AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, currentZone, targetZone, task) {
46-
if (task.type == 'macroTask' && task.source == 'setInterval') {
47-
this._failCallback('Cannot use setInterval from within an async zone test.');
48-
return;
49-
}
50-
return delegate.scheduleTask(targetZone, task);
51-
};
52-
AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) {
53-
delegate.hasTask(target, hasTaskState);
54-
if (hasTaskState.change == 'microTask') {
55-
this._pendingMicroTasks = hasTaskState.microTask;
56-
this._finishCallbackIfDone();
57-
}
58-
else if (hasTaskState.change == 'macroTask') {
59-
this._pendingMacroTasks = hasTaskState.macroTask;
60-
this._finishCallbackIfDone();
61-
}
62-
};
63-
return AsyncTestZoneSpec;
64-
}());
65-
// Export the class so that new instances can be created with proper
66-
// constructor params.
67-
Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec;
68-
})();
36+
};
37+
// Note - we need to use onInvoke at the moment to call finish when a test is
38+
// fully synchronous. TODO(juliemr): remove this when the logic for
39+
// onHasTask changes and it calls whenever the task queues are dirty.
40+
AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) {
41+
try {
42+
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);
43+
}
44+
finally {
45+
this._finishCallbackIfDone();
46+
}
47+
};
48+
AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
49+
// Let the parent try to handle the error.
50+
var result = parentZoneDelegate.handleError(targetZone, error);
51+
if (result) {
52+
this._failCallback(error);
53+
this._alreadyErrored = true;
54+
}
55+
return false;
56+
};
57+
AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, currentZone, targetZone, task) {
58+
if (task.type == 'macroTask' && task.source == 'setInterval') {
59+
this._failCallback('Cannot use setInterval from within an async zone test.');
60+
return;
61+
}
62+
return delegate.scheduleTask(targetZone, task);
63+
};
64+
AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) {
65+
delegate.hasTask(target, hasTaskState);
66+
if (hasTaskState.change == 'microTask') {
67+
this._pendingMicroTasks = hasTaskState.microTask;
68+
this._finishCallbackIfDone();
69+
}
70+
else if (hasTaskState.change == 'macroTask') {
71+
this._pendingMacroTasks = hasTaskState.macroTask;
72+
this._finishCallbackIfDone();
73+
}
74+
};
75+
return AsyncTestZoneSpec;
76+
}());
77+
// Export the class so that new instances can be created with proper
78+
// constructor params.
79+
Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec;
80+
81+
})));

0 commit comments

Comments
 (0)