From a8ca469a65080c01cae8b6e84b3ae010e9a74965 Mon Sep 17 00:00:00 2001 From: dormouse-bot <287024035+dormouse-bot@users.noreply.github.com> Date: Mon, 10 Aug 2026 08:12:59 +0000 Subject: [PATCH] test(throttle): assert the trailing call actually fires MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/src/lib/throttle.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/lib/throttle.test.ts b/lib/src/lib/throttle.test.ts index 491cdaad..ef74b8d4 100644 --- a/lib/src/lib/throttle.test.ts +++ b/lib/src/lib/throttle.test.ts @@ -38,9 +38,13 @@ describe('throttleTrailing', () => { expect(duringBurst).toBeLessThanOrEqual(5); // Let everything settle — a final trailing call fits the resting geometry. + // Strictly greater than the burst count: the last frame left a trailing + // call pending, so exactly one more fire must land after settling. + // (`> duringBurst - 1` would be `>= duringBurst`, which holds even if no + // trailing call fired, defeating the check.) vi.advanceTimersByTime(300); const total = fn.mock.calls.length; - expect(total).toBeGreaterThan(duringBurst - 1); + expect(total).toBeGreaterThan(duringBurst); expect(total).toBeLessThanOrEqual(5); });