Skip to content

test(format): Add unit tests for XLM amount formatter (#39) - #44

Merged
Chucks1093 merged 1 commit into
StellarState:devfrom
abdulqoyumadegoke:test/39-xlm-amount-formatter-tests
Jul 30, 2026
Merged

test(format): Add unit tests for XLM amount formatter (#39)#44
Chucks1093 merged 1 commit into
StellarState:devfrom
abdulqoyumadegoke:test/39-xlm-amount-formatter-tests

Conversation

@abdulqoyumadegoke

Copy link
Copy Markdown
Contributor

Closes #39

Overview

Resolves #39 by adding a standardized formatXLM amount formatting utility function (lib/format.ts) and unit test suite (lib/__tests__/formatXLM.test.ts) that guarantees correct thousand separators, two fixed decimal places, and accurate handling of zero, fractional, and negative XLM values without floating-point representation errors.

Key Changes

  • lib/format.ts: Implemented formatXLM utility handling number | string | bigint inputs, appending trailing XLM suffixes with en-US thousand separators (1,000,000.00 XLM) and fallback safety.
  • lib/portfolio.ts: Updated portfolio summary total calculation to use formatXLM.
  • lib/__tests__/formatXLM.test.ts:
    • Added unit test cases verifying 10000 -> '10,000.00 XLM'.
    • Added unit test cases verifying 0 -> '0.00 XLM'.
    • Added unit test cases verifying 0.5 -> '0.50 XLM'.
    • Added unit test cases verifying 1000000 -> '1,000,000.00 XLM'.
    • Added unit test cases verifying negative values (-500) -> '-500.00 XLM'.
    • Verified floating-point rounding precision (0.1 + 0.2 -> '0.30 XLM', 1234.5678 -> '1,234.57 XLM').

Verification

  • Verified unit test suite assertions.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@abdulqoyumadegoke Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@abdulqoyumadegoke
abdulqoyumadegoke force-pushed the test/39-xlm-amount-formatter-tests branch from 4ea5cb5 to b274d94 Compare July 30, 2026 05:57
@abdulqoyumadegoke
abdulqoyumadegoke changed the base branch from main to dev July 30, 2026 05:58
@Chucks1093
Chucks1093 merged commit 3fb141f into StellarState:dev Jul 30, 2026
1 of 2 checks passed
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.

Add unit tests for the XLM amount formatter displaying correct thousand separators and decimal places

2 participants