Skip to content

test(#319, #320): add comprehensive test coverage for api.ts and contract.ts - #1

Open
Uchechukwu-Ekezie wants to merge 1 commit into
mainfrom
fixes/parashield-319-320
Open

test(#319, #320): add comprehensive test coverage for api.ts and contract.ts#1
Uchechukwu-Ekezie wants to merge 1 commit into
mainfrom
fixes/parashield-319-320

Conversation

@Uchechukwu-Ekezie

Copy link
Copy Markdown

Fixes Parashield-Protocol#319 Parashield-Protocol#320

Summary

Implements comprehensive test coverage for two critical library modules:

Issue Parashield-Protocol#319 - api.ts tests:

Issue Parashield-Protocol#320 - contract.ts tests:

Test coverage

  • Added src/lib/__tests__/api.test.ts - 292 lines covering api module
  • Added src/lib/__tests__/contract.test.ts - 260 lines covering contract module
  • Total: 552 lines of test code

Related issues

Testing

These tests verify critical error handling paths and transaction encoding that impact production behavior. No breaking changes to existing code.

…sive test coverage for api.ts and contract.ts

Implements test suites for api.ts (issue Parashield-Protocol#319) and contract.ts (issue Parashield-Protocol#320):

api.test.ts:
- Tests unwrap() throws ApiError on success:false even with HTTP 200 (issue Parashield-Protocol#198)
- Tests withRetry() behavior: retries 5xx errors with exponential backoff, throws immediately on 4xx
- Tests auth interceptor adds Bearer token when session exists
- Tests auth error handler called on 401 responses
- Tests endpoint behavior for 404 handling in fetchClaim() and fetchOracleReading()

contract.test.ts:
- Tests buildBuyPolicyTx() encodes oracle key as {type: 'string'} not {type: 'symbol'} (issue Parashield-Protocol#194 regression)
- Tests simulateContractCall() throws ContractError with sanitized message and raw diagnostic in .details
- Tests transaction building, signing, and submission flows for buyPolicy and claim operations
- Tests poll-for-confirmation timeout handling
- Tests RPC singleton caching for connection pool efficiency (issue Parashield-Protocol#129)
- Tests BuyPolicyResult returns signedXdr for backend verification (issue Parashield-Protocol#195)
@Uchechukwu-Ekezie
Uchechukwu-Ekezie force-pushed the fixes/parashield-319-320 branch from 58c42dc to 7c1d3b0 Compare July 25, 2026 22:09
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.

[Test coverage] api.ts has no test coverage

1 participant