Skip to content

Commit

Permalink
debouncer: also test waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
hbbio committed May 26, 2024
1 parent 2bb4fd5 commit 8662a86
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/debouncer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 8662a86

Please sign in to comment.