Skip to content

Commit

Permalink
Fix for *Async time forwarders
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Oct 19, 2023
1 parent 3861bb8 commit 9802829
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/fake-timers-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,8 @@ function withGlobal(_global) {
function doRun() {
originalSetTimeout(function () {
try {
runJobs(clock);

let numTimers;
if (i < clock.loopLimit) {
if (!clock.timers) {
Expand Down Expand Up @@ -1633,6 +1635,7 @@ function withGlobal(_global) {
try {
const timer = lastTimer(clock);
if (!timer) {
runJobs(clock);
resolve(clock.now);
}

Expand Down
4 changes: 3 additions & 1 deletion test/issue-async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ describe("bug", function () {
it(`should advance past queued microtasks using ${fastForward}`, async function () {
const cb = sinon.fake();
myFn(cb);
myFn(cb);
myFn(cb);
await clock[fastForward]();
assert.equal(cb.callCount, 1);
assert.equal(cb.callCount, 3);
});
});
});
Expand Down

0 comments on commit 9802829

Please sign in to comment.