Skip to content

Commit

Permalink
test: make debounce decorator test more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
senyai committed May 11, 2024
1 parent fec72f0 commit 98b7d58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/test/suite/utilitiesSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,18 @@ function decoratorsSuite(this: Suite) {
}

const dt = new DebounceTest();
assert.equal(fakeTimers.countTimers(), 0);
const p0 = dt.debounced_method();
assert.equal(fakeTimers.countTimers(), 1);
const p1 = dt.debounced_method();
const p2 = dt.debounced_method();
const resPromise = Promise.race([p0, p1, p2]);
assert.equal(await resPromise, undefined);
assert.equal(fakeTimers.countTimers(), 1);
const debounceTimer = await fakeTimers.nextAsync();
assert.equal(fakeTimers.countTimers(), 0);
assert.equal(await resPromise, undefined);
assert.equal(debounceTimer, startTimeStamp + 50, 'main timer worked');
assert.equal(dt.debounce_count, 1, 'reached main timer only');
assert.equal(fakeTimers.countTimers(), 0);
});
}

Expand Down

0 comments on commit 98b7d58

Please sign in to comment.