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

Commit 667cd6f

Browse files
nertzymhevery
authored andcommitted
fix(spec): FakeAsyncTestZoneSpec.flush() passes limit along to scheduler (#831)
Signed-off-by: Michael Stuart <mistuart@corelogic.com>
1 parent 273cb85 commit 667cd6f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/zone-spec/fake-async-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@
249249
flushErrors();
250250
}
251251

252-
flush(): number {
252+
flush(limit?: number): number {
253253
FakeAsyncTestZoneSpec.assertInZone();
254254
this.flushMicrotasks();
255-
let elapsed = this._scheduler.flush();
255+
let elapsed = this._scheduler.flush(limit);
256256
if (this._lastError !== null) {
257257
this._resetLastErrorAndThrow();
258258
}

test/zone-spec/fake-async-test.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,26 @@ describe('FakeAsyncTestZoneSpec', () => {
501501
.toThrowError(
502502
'flush failed after reaching the limit of 20 tasks. Does your code use a polling timeout?');
503503
});
504+
505+
it('accepts a custom limit', function() {
506+
expect(() => {
507+
fakeAsyncTestZone.run(() => {
508+
let z = 0;
509+
510+
let poll = () => {
511+
setTimeout(() => {
512+
z++;
513+
poll();
514+
}, 10);
515+
};
516+
517+
poll();
518+
testZoneSpec.flush(10);
519+
});
520+
})
521+
.toThrowError(
522+
'flush failed after reaching the limit of 10 tasks. Does your code use a polling timeout?');
523+
});
504524
});
505525

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

0 commit comments

Comments
 (0)