Revert "fix(core): fix chained http call (#20924)"
This reverts commit 7e3f9a482a
.
This commit is contained in:
parent
0eabd07f3a
commit
47b7898697
|
@ -98,22 +98,13 @@ export class Testability implements PublicTestability {
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_runCallbacksIfReady(): void {
|
_runCallbacksIfReady(): void {
|
||||||
if (this.isStable()) {
|
if (this.isStable()) {
|
||||||
if (this._callbacks.length !== 0) {
|
// Schedules the call backs in a new frame so that it is always async.
|
||||||
// Schedules the call backs after a macro task run outside of the angular zone to make sure
|
scheduleMicroTask(() => {
|
||||||
// no new task are added
|
|
||||||
this._ngZone.runOutsideAngular(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.isStable()) {
|
|
||||||
while (this._callbacks.length !== 0) {
|
while (this._callbacks.length !== 0) {
|
||||||
(this._callbacks.pop() !)(this._didWork);
|
(this._callbacks.pop() !)(this._didWork);
|
||||||
}
|
}
|
||||||
this._didWork = false;
|
this._didWork = false;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this._didWork = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Not Ready
|
// Not Ready
|
||||||
this._didWork = true;
|
this._didWork = true;
|
||||||
|
|
|
@ -16,11 +16,13 @@ import {scheduleMicroTask} from '../../src/util';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Schedules a task to be run after Testability checks for oustanding tasks. Since Testability
|
// Schedules a microtasks (using a resolved promise .then())
|
||||||
// uses a 0 second timeout to check for outstanding tasks we add our 0 second timeout after a
|
function microTask(fn: Function): void {
|
||||||
// micro task (which ensures Testability's timeout is run first).
|
scheduleMicroTask(() => {
|
||||||
function afterTestabilityCheck(fn: Function): void {
|
// We do double dispatch so that we can wait for scheduleMicrotask in the Testability when
|
||||||
scheduleMicroTask(() => setTimeout(fn));
|
// NgZone becomes stable.
|
||||||
|
scheduleMicroTask(fn);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -63,7 +65,7 @@ class MockNgZone extends NgZone {
|
||||||
it('should fire whenstable callbacks if pending count is 0',
|
it('should fire whenstable callbacks if pending count is 0',
|
||||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalled();
|
expect(execute).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -80,11 +82,11 @@ class MockNgZone extends NgZone {
|
||||||
testability.increasePendingRequestCount();
|
testability.increasePendingRequestCount();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
testability.decreasePendingRequestCount();
|
testability.decreasePendingRequestCount();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -96,11 +98,11 @@ class MockNgZone extends NgZone {
|
||||||
testability.increasePendingRequestCount();
|
testability.increasePendingRequestCount();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
testability.decreasePendingRequestCount();
|
testability.decreasePendingRequestCount();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalled();
|
expect(execute).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -118,7 +120,7 @@ class MockNgZone extends NgZone {
|
||||||
it('should fire whenstable callbacks with didWork if pending count is 0',
|
it('should fire whenstable callbacks with didWork if pending count is 0',
|
||||||
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalledWith(false);
|
expect(execute).toHaveBeenCalledWith(false);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -129,14 +131,14 @@ class MockNgZone extends NgZone {
|
||||||
testability.increasePendingRequestCount();
|
testability.increasePendingRequestCount();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
testability.decreasePendingRequestCount();
|
testability.decreasePendingRequestCount();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalledWith(true);
|
expect(execute).toHaveBeenCalledWith(true);
|
||||||
testability.whenStable(execute2);
|
testability.whenStable(execute2);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute2).toHaveBeenCalledWith(false);
|
expect(execute2).toHaveBeenCalledWith(false);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -152,7 +154,7 @@ class MockNgZone extends NgZone {
|
||||||
ngZone.stable();
|
ngZone.stable();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalled();
|
expect(execute).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -171,11 +173,11 @@ class MockNgZone extends NgZone {
|
||||||
ngZone.unstable();
|
ngZone.unstable();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
ngZone.stable();
|
ngZone.stable();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalled();
|
expect(execute).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -196,15 +198,15 @@ class MockNgZone extends NgZone {
|
||||||
testability.increasePendingRequestCount();
|
testability.increasePendingRequestCount();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
testability.decreasePendingRequestCount();
|
testability.decreasePendingRequestCount();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
ngZone.stable();
|
ngZone.stable();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalled();
|
expect(execute).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -219,19 +221,19 @@ class MockNgZone extends NgZone {
|
||||||
testability.increasePendingRequestCount();
|
testability.increasePendingRequestCount();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
ngZone.stable();
|
ngZone.stable();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
testability.decreasePendingRequestCount();
|
testability.decreasePendingRequestCount();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).not.toHaveBeenCalled();
|
expect(execute).not.toHaveBeenCalled();
|
||||||
testability.decreasePendingRequestCount();
|
testability.decreasePendingRequestCount();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalled();
|
expect(execute).toHaveBeenCalled();
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -246,11 +248,11 @@ class MockNgZone extends NgZone {
|
||||||
ngZone.stable();
|
ngZone.stable();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalledWith(true);
|
expect(execute).toHaveBeenCalledWith(true);
|
||||||
testability.whenStable(execute2);
|
testability.whenStable(execute2);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute2).toHaveBeenCalledWith(false);
|
expect(execute2).toHaveBeenCalledWith(false);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
@ -262,14 +264,14 @@ class MockNgZone extends NgZone {
|
||||||
ngZone.unstable();
|
ngZone.unstable();
|
||||||
testability.whenStable(execute);
|
testability.whenStable(execute);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
ngZone.stable();
|
ngZone.stable();
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute).toHaveBeenCalledWith(true);
|
expect(execute).toHaveBeenCalledWith(true);
|
||||||
testability.whenStable(execute2);
|
testability.whenStable(execute2);
|
||||||
|
|
||||||
afterTestabilityCheck(() => {
|
microTask(() => {
|
||||||
expect(execute2).toHaveBeenCalledWith(false);
|
expect(execute2).toHaveBeenCalledWith(false);
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue