Skip to content

Commit

Permalink
test: add failing asapScheduler test
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Apr 21, 2020
1 parent e438246 commit 85fe981
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/schedulers/AsapScheduler-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,32 @@ describe('Scheduler.asap', () => {
firstSubscription.unsubscribe();
}
});

it('should not execute rescheduled actions when flushing', (done: MochaDone) => {
let flushCount = 0;
let scheduledIndices: number[] = [];

let originalFlush = asap.flush;
asap.flush = (...args) => {
++flushCount;
originalFlush.apply(asap, args);
if (flushCount === 2) {
asap.flush = originalFlush;
try {
expect(scheduledIndices).to.deep.equal([0, 1]);
done();
} catch (error) {
done(error);
}
}
};

asap.schedule(function (index) {
if (flushCount < 2) {
this.schedule(index! + 1);
scheduledIndices.push(index! + 1);
}
}, 0, 0);
scheduledIndices.push(0);
});
});

0 comments on commit 85fe981

Please sign in to comment.