Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/__tests__/Squawk.pending.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
Loading