Skip to content

test: fix hedge-walk mock queues so cap logic is actually exercised - #120

Merged
kunalrbhatia merged 1 commit into
developmentfrom
fix/hedge-walk-test-queues
Sep 3, 2026
Merged

kunalrbhatia merged 1 commit into
developmentfrom
fix/hedge-walk-test-queues

Conversation

@kunalrbhatia

Copy link
Copy Markdown
Owner

Summary

Fix the hedge-walk unit tests added in PR #118 — mock queues were ordered incorrectly, so the PE-hedge walk never exercised the cap logic.

Why

The 3 tests added with PR #118 used .mockResolvedValue(false) (a default) interleaved with .mockResolvedValueOnce() entries. Jest consumes once-queue values in registration order BEFORE falling back to the default — so the PE hedge "succeeded" on its first attempt (consuming the value meant for CE Sell) and the walk/cap code path was never tested. Result: tests expected 8 calls, got 4, and CI on development was red after the docs PR #119 merged.

Change

Rewrote the 3 tests with fully deterministic mockResolvedValueOnce queues matching the exact call sequence (CE hedge + 6 PE attempts + 2 sells = 9 calls; CE-walk variant = 6; CE-cap variant = 9).

Verification

  • Jest: all 3 tests pass, expecting exact call counts (9/6/9).
  • Full suite green (coverage threshold 80% restored).

@kunalrbhatia
kunalrbhatia merged commit 2b9cf45 into development Sep 3, 2026
12 checks passed
@kunalrbhatia
kunalrbhatia deleted the fix/hedge-walk-test-queues branch September 3, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant