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

Commit

Permalink
fix(spec): FakeAsyncTestZoneSpec.flush() passes limit along to schedu…
Browse files Browse the repository at this point in the history
…ler (#831)

Signed-off-by: Michael Stuart <[email protected]>
  • Loading branch information
nertzy authored and mhevery committed Jul 12, 2017
1 parent 273cb85 commit 667cd6f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zone-spec/fake-async-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@
flushErrors();
}

flush(): number {
flush(limit?: number): number {
FakeAsyncTestZoneSpec.assertInZone();
this.flushMicrotasks();
let elapsed = this._scheduler.flush();
let elapsed = this._scheduler.flush(limit);
if (this._lastError !== null) {
this._resetLastErrorAndThrow();
}
Expand Down
20 changes: 20 additions & 0 deletions test/zone-spec/fake-async-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,26 @@ describe('FakeAsyncTestZoneSpec', () => {
.toThrowError(
'flush failed after reaching the limit of 20 tasks. Does your code use a polling timeout?');
});

it('accepts a custom limit', function() {
expect(() => {
fakeAsyncTestZone.run(() => {
let z = 0;

let poll = () => {
setTimeout(() => {
z++;
poll();
}, 10);
};

poll();
testZoneSpec.flush(10);
});
})
.toThrowError(
'flush failed after reaching the limit of 10 tasks. Does your code use a polling timeout?');
});
});

describe('outside of FakeAsync Zone', () => {
Expand Down

0 comments on commit 667cd6f

Please sign in to comment.