test(throttle): assert the trailing call actually fires - #365
Merged
Conversation
The burst test's post-settle assertion was `toBeGreaterThan(duringBurst - 1)`, i.e. `>= duringBurst`. Since mock call counts only grow, that holds even if no trailing call fired after the burst — the test's stated purpose (one final trailing fire) was never verified. Tighten to `> duringBurst` so a regression that drops the trailing call fails the test.
Deploying mouseterm with
|
| Latest commit: |
a8ca469
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5f3679da.mouseterm.pages.dev |
| Branch Preview URL: | https://test-throttle-trailing-asser.mouseterm.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "coalesces a burst" test in
throttle.test.tsasserts a final trailing call fires after the burst settles, but the check was ineffective:totalis a mock call count taken afterduringBurst, and call counts only ever grow, sototal >= duringBurstis trivially true. IfthrottleTrailingregressed and fired no trailing call after the burst,totalwould equalduringBurstand the assertion would still pass — the test's stated purpose ("a final trailing call fits the resting geometry") was never actually verified.Fix
Tighten to
expect(total).toBeGreaterThan(duringBurst)so exactly-one-more fire after settling is required. With the current implementation the burst leaves a trailing call pending on the last frame, so one more fire lands during the +300ms settle and the strict assertion passes; a regression that dropped the trailing call would now fail. Test-only change — no production code touched.