Skip to content

Expand pay() test coverage: timeout, 402 retry, insufficient balance #9

@RBKunnela

Description

@RBKunnela

Follow-up from #8 review. CodeRabbit's last nitpick on PR #8 flagged that tests/client.test.ts has strong happy-path and generic-failure coverage for pay(), but three payment-flow edges are still untested:

  1. TimeoutmockFetch rejects with new Error('ETIMEDOUT') on both attempts; assert client.pay returns success: false and error contains ETIMEDOUT.
  2. 402 retrymockFetch first returns 402 { error: 'Payment required', code: 'PAYMENT_REQUIRED' }, then succeeds on retry; assert success: true and mockFetch was called twice.
  3. Insufficient balanceverify returns valid with settlementToken, but settle returns 402 { error: 'Insufficient balance', code: 'INSUFFICIENT_FUNDS' }; assert success: false and errorCode === 'INSUFFICIENT_FUNDS'.

All three should follow the same mockFetch / client.pay shape as the surrounding tests, with body inspection via mockFetch.mock.calls.

Good first issue for a TS contributor. Not a blocker for #8 merge — kept that PR receipt-scoped.

Per coding guidelines tests/**: covers "Coverage of payment flow edge cases (402 retry, balance insufficient, timeout)".

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions