Skip to content

test(internal): add comprehensive tests and improve documentation#2601

Open
Dark-Brain07 wants to merge 5 commits intocoinbase:mainfrom
Dark-Brain07:feature/improve-tests-and-documentation
Open

test(internal): add comprehensive tests and improve documentation#2601
Dark-Brain07 wants to merge 5 commits intocoinbase:mainfrom
Dark-Brain07:feature/improve-tests-and-documentation

Conversation

@Dark-Brain07
Copy link

What changed? Why?

This PR improves test coverage and documentation across the OnchainKit codebase:

  1. Added tests for isApiError utility - This internal utility was previously untested. Added comprehensive test suite covering valid API error responses, edge cases (null, undefined, empty objects), and non-error types. Also added JSDoc documentation with usage examples.

  2. Added tests for prefixStringParts utility - Added missing test coverage for this string manipulation utility, including tests for basic prefixing, whitespace handling, edge cases, and CSS class name patterns.

  3. Enhanced getSwapErrorCode with additional JSON-RPC error codes - Addressed the TODO comment by adding support for -32603 (Internal JSON-RPC error) and -32000 (Server error). Added INTERNAL_ERROR_CODE and SERVER_ERROR_CODE constants with comprehensive JSDoc documentation.

  4. Improved JSDoc documentation for core utilities - Enhanced isBase and isEthereum functions with proper @param, @returns, and @example tags to improve developer experience.

  5. Added edge case tests for formatPercent utility - Expanded test coverage to include very small numbers, very large values, special values (Infinity, -Infinity, NaN), high precision decimal places, and rounding behavior verification.

Notes to reviewers

  • All new tests follow existing testing patterns using Vitest
  • The getSwapErrorCode change addresses an existing TODO in the codebase
  • Documentation improvements use standard JSDoc format consistent with the rest of the codebase
  • Tests are organized into logical describe blocks for better readability

How has it been tested?

  • All changes include comprehensive unit tests
  • Run pnpm f:ock test to verify all tests pass
  • Run pnpm f:ock lint and pnpm f:ock typecheck to verify code quality

@cb-heimdall
Copy link

cb-heimdall commented Jan 28, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link

vercel bot commented Jan 28, 2026

Someone is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@Dark-Brain07 Dark-Brain07 force-pushed the feature/improve-tests-and-documentation branch 3 times, most recently from 5a32250 to debca35 Compare February 14, 2026 10:14
- Add INTERNAL_ERROR_CODE and SERVER_ERROR_CODE constants
- Handle -32603 (internal error) and -32000 (server error) codes
- Add JSDoc documentation for getSwapErrorCode function
- Reorganize and expand test coverage with better structure
…lities

- Add comprehensive JSDoc with @param, @returns, and @example tags
- Include usage examples with expected return values
- Document the isMainnetOnly parameter behavior
- Improve clarity of function descriptions
- Add tests for very small positive and negative numbers
- Add tests for very large percentage values
- Add tests for special values (Infinity, -Infinity, NaN)
- Add tests for high precision decimal places
- Add tests for rounding behavior
- Reorganize tests into logical describe blocks
@Dark-Brain07 Dark-Brain07 force-pushed the feature/improve-tests-and-documentation branch from debca35 to 1986270 Compare February 14, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants