From 899d10dcfcacf81bb1d9a400091a9883e6d35a23 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 20:38:56 +0000 Subject: [PATCH] test: add test for pending count dropping below zero - Added new test file `src/__tests__/Squawk.pending.test.ts` - Verifies that calling store.pending("prop", false) throws an Error when count is already 0 - Included happy path test to verify normal pending true/false usage - Improves testing coverage for Squawk error conditions Co-authored-by: johnstrand <11484777+johnstrand@users.noreply.github.com> --- src/__tests__/Squawk.pending.test.ts | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/__tests__/Squawk.pending.test.ts diff --git a/src/__tests__/Squawk.pending.test.ts b/src/__tests__/Squawk.pending.test.ts new file mode 100644 index 0000000..8f4f570 --- /dev/null +++ b/src/__tests__/Squawk.pending.test.ts @@ -0,0 +1,30 @@ +import createStore from "../Squawk"; + +describe("Squawk pending", () => { + it("throws error when pending count drops below zero", () => { + const store = createStore({ + testProp: "initial" + }); + + // Calling pending with false when count is 0 should throw + expect(() => { + store.pending("testProp", false); + }).toThrowError('Too many calls to pending("testProp", false)'); + }); + + it("handles happy path of pending correctly", () => { + const store = createStore({ + testProp: "initial" + }); + + // Initially setting to true should not throw + expect(() => { + store.pending("testProp", true); + }).not.toThrow(); + + // Setting back to false should also not throw (count returns to 0) + expect(() => { + store.pending("testProp", false); + }).not.toThrow(); + }); +});