Skip to content

Add comprehensive Jest unit tests for cryptoformat module#76

Merged
jasonjul merged 1 commit intomasterfrom
devin/1756275950-add-jest-tests
Aug 28, 2025
Merged

Add comprehensive Jest unit tests for cryptoformat module#76
jasonjul merged 1 commit intomasterfrom
devin/1756275950-add-jest-tests

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Aug 27, 2025

Add comprehensive Jest unit tests for cryptoformat module (rebased for Jest v30)

Summary

This PR adds 317 lines of comprehensive Jest unit tests to src/test.js, expanding test coverage from basic functionality to extensive edge cases, error conditions, and boundary testing for all exported functions (formatCurrency, isCrypto, clearCache) and internal helper functions.

The PR has been rebased from master to include the Jest v30.1.1 upgrade (previously v24.9.0). All 72 tests pass with the new Jest version.

Key test additions:

  • Internal helper function testing: isBTCETH, IntlNumberFormatSupported, fallback behavior
  • Edge case coverage: Invalid inputs (null, undefined, NaN, Infinity), boundary values, locale-specific cases
  • Error handling: Unsupported currencies, invalid locales, global state corruption scenarios
  • Caching mechanism: Verification that clearCache() works and formatters are reused appropriately
  • Symbol overrides: Currency symbol customization functionality
  • Complex parameters: Decimal places, significant figures, trailing zeroes handling
  • Fallback scenarios: Behavior when Intl.NumberFormat is unavailable

Review & Testing Checklist for Human

  • Verify test expectations are correct - Some test expectations were adjusted during development, manually verify key behaviors match actual library output
  • Test Jest v30 compatibility - Run tests in your local environment and CI to ensure the major Jest upgrade doesn't introduce issues
  • Manual spot-check edge cases - Try some of the edge cases manually (very small numbers, invalid inputs, etc.) to verify test expectations
  • Review global state handling - Tests modify global.Intl - ensure this doesn't cause issues in your test environment

Notes

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Original prompt from cedric@coingecko.com
In the cryptoformat repo, look into the file https://github.com/coingecko/cryptoformat/blob/master/src/index.js. Set up unit tests for this module to test all happy path and edge cases for each function using Jest

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Add extensive test coverage for internal helper functions (isBTCETH, IntlNumberFormatSupported)
- Add edge case testing for invalid inputs (null, undefined, NaN, Infinity)
- Add boundary value testing for crypto and fiat currency thresholds
- Add locale-specific edge case testing
- Add caching mechanism verification tests
- Add symbol override functionality tests
- Add decimal trailing zeroes functionality tests
- Add complex parameter combination tests
- Add fallback formatter behavior tests
- All 72 tests pass, providing comprehensive coverage of happy paths and edge cases

Co-Authored-By: cedric@coingecko.com <cedric@coingecko.com>
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1756275950-add-jest-tests branch from 8481b4a to ebb3d4d Compare August 28, 2025 08:31
Copy link
Copy Markdown
Collaborator

@jasonjul jasonjul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, Devin's work

@jasonjul jasonjul merged commit d8e5e49 into master Aug 28, 2025
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