Revert "fix(core): fix chained http call (#20924)"

This reverts commit 54e75766ad.
This commit is contained in:
Miško Hevery
2018-01-19 13:06:33 -08:00
parent af4eb00c91
commit 0d55600fd8
2 changed files with 37 additions and 44 deletions

View File

@ -16,11 +16,13 @@ import {scheduleMicroTask} from '../../src/util';
// Schedules a task to be run after Testability checks for oustanding tasks. Since Testability
// uses a 0 second timeout to check for outstanding tasks we add our 0 second timeout after a
// micro task (which ensures Testability's timeout is run first).
function afterTestabilityCheck(fn: Function): void {
scheduleMicroTask(() => setTimeout(fn));
// Schedules a microtasks (using a resolved promise .then())
function microTask(fn: Function): void {
scheduleMicroTask(() => {
// We do double dispatch so that we can wait for scheduleMicrotask in the Testability when
// NgZone becomes stable.
scheduleMicroTask(fn);
});
}
@Injectable()
@ -63,7 +65,7 @@ class MockNgZone extends NgZone {
it('should fire whenstable callbacks if pending count is 0',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalled();
async.done();
});
@ -80,11 +82,11 @@ class MockNgZone extends NgZone {
testability.increasePendingRequestCount();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
testability.decreasePendingRequestCount();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
async.done();
});
@ -96,11 +98,11 @@ class MockNgZone extends NgZone {
testability.increasePendingRequestCount();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
testability.decreasePendingRequestCount();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalled();
async.done();
});
@ -118,7 +120,7 @@ class MockNgZone extends NgZone {
it('should fire whenstable callbacks with didWork if pending count is 0',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalledWith(false);
async.done();
});
@ -129,14 +131,14 @@ class MockNgZone extends NgZone {
testability.increasePendingRequestCount();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
testability.decreasePendingRequestCount();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalledWith(true);
testability.whenStable(execute2);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute2).toHaveBeenCalledWith(false);
async.done();
});
@ -152,7 +154,7 @@ class MockNgZone extends NgZone {
ngZone.stable();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalled();
async.done();
});
@ -171,11 +173,11 @@ class MockNgZone extends NgZone {
ngZone.unstable();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
ngZone.stable();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalled();
async.done();
});
@ -196,15 +198,15 @@ class MockNgZone extends NgZone {
testability.increasePendingRequestCount();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
testability.decreasePendingRequestCount();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
ngZone.stable();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalled();
async.done();
});
@ -219,19 +221,19 @@ class MockNgZone extends NgZone {
testability.increasePendingRequestCount();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
ngZone.stable();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
testability.decreasePendingRequestCount();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).not.toHaveBeenCalled();
testability.decreasePendingRequestCount();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalled();
async.done();
});
@ -246,11 +248,11 @@ class MockNgZone extends NgZone {
ngZone.stable();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalledWith(true);
testability.whenStable(execute2);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute2).toHaveBeenCalledWith(false);
async.done();
});
@ -262,14 +264,14 @@ class MockNgZone extends NgZone {
ngZone.unstable();
testability.whenStable(execute);
afterTestabilityCheck(() => {
microTask(() => {
ngZone.stable();
afterTestabilityCheck(() => {
microTask(() => {
expect(execute).toHaveBeenCalledWith(true);
testability.whenStable(execute2);
afterTestabilityCheck(() => {
microTask(() => {
expect(execute2).toHaveBeenCalledWith(false);
async.done();
});