Skip to content

test: add unit tests for components/ui/token-amount.tsx - #556

Merged
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
peterexcel494-oss:feat/add-token-amount-tests
Aug 20, 2026
Merged

test: add unit tests for components/ui/token-amount.tsx#556
Austinaminu2 merged 1 commit into
FlowwStar:mainfrom
peterexcel494-oss:feat/add-token-amount-tests

Conversation

@peterexcel494-oss

Copy link
Copy Markdown
Contributor

Summary

Closes #509

Adds a comprehensive unit test suite for components/ui/token-amount.tsx, which had no test coverage prior to this PR.

What was tested

The test file is located at __tests__/components/token-amount.tsx and covers:

  • Formatted display — zero, whole numbers, fractions, large amounts with thousands separators (e.g. 1,234,567), and negative amounts
  • Decimal handling — 7-decimal tokens (USDC, XLM, EURC) and 0-decimal tokens; maxFractionDigits prop overrides at 0, 2, and default 4
  • Symbol rendering — symbol visible by default, hidden via showSymbol={false}, correct symbol per token, and custom symbolClassName applied
  • Compact notationcompact prop produces K/M suffixes (e.g. 1.2K, 2.5M), with symbol show/hide also tested in compact mode
  • CSS / className passthrough — outer span always carries font-mono and tabular-nums, and accepts extra classes via className

Test results

24 tests, all passing. token-amount.tsx achieves 100% statement/branch/function/line coverage.

Test Files  1 passed (1)
     Tests  24 passed (24)

Notes

6 pre-existing test failures in use-contract.test.ts and use-token-price.test.ts are unrelated to this change and were already failing on main before this PR.

Closes FlowwStar#509

- Tests formatted display across representative values (zero, whole
  numbers, fractions, large amounts with thousand separators, negatives)
- Tests decimal handling for 7-decimal tokens (USDC, XLM, EURC) and
  0-decimal tokens, plus maxFractionDigits overrides
- Tests symbol rendering: visible by default, hidden via showSymbol=false,
  custom symbolClassName applied correctly
- Tests compact notation mode (K/M suffixes) via the compact prop
- Tests className and base CSS class passthrough on the outer span
- 24 tests, all passing (100% branch/statement/function/line coverage
  on token-amount.tsx)
@Austinaminu2
Austinaminu2 merged commit acbbce7 into FlowwStar:main Aug 20, 2026
0 of 6 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 components/ui/token-amount.tsx

2 participants