From 8662a867f0a7071dd845dee670420bf4a7dc6243 Mon Sep 17 00:00:00 2001 From: Henri Binsztok <808274+hbbio@users.noreply.github.com> Date: Sun, 26 May 2024 15:03:27 +0800 Subject: [PATCH] debouncer: also test waiting --- src/debouncer.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/debouncer.test.ts b/src/debouncer.test.ts index d715d51..0bbc838 100644 --- a/src/debouncer.test.ts +++ b/src/debouncer.test.ts @@ -10,11 +10,16 @@ test("debouncer", async () => { const waiting = proxy.new(false); const deb = debouncer(20, waiting); const v = proxy.new(0); + expect(waiting.consolidatedValue).toBe(false); + for (let i = 1; i <= 10; i++) { deb((i) => v.set(i), i); await sleep(5); expect(v.consolidatedValue).toBe(0); + expect(waiting.consolidatedValue).toBe(true); } + await sleep(30); expect(v.consolidatedValue).toBe(10); + expect(waiting.consolidatedValue).toBe(false); });