Skip to content

test(formatXlm): add edge case coverage for large numbers, fractional amounts, and negative values - #975

Open
waterWang wants to merge 2 commits into
scout-off:mainfrom
waterWang:test/formatxlm-edge-cases-871
Open

test(formatXlm): add edge case coverage for large numbers, fractional amounts, and negative values#975
waterWang wants to merge 2 commits into
scout-off:mainfrom
waterWang:test/formatxlm-edge-cases-871

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Closes #871

Expands __tests__/lib/formatXlm.test.ts with edge-case coverage requested in the issue:

  • Very large XLM amounts (1_000_000, 999999999) — verifies output is a fixed-point string without scientific notation.
  • Extremely small fractional amounts (0.0000001, 0.004, 0.006) — verifies rounding to the configured 2-decimal precision at Stellar's smallest unit.
  • Negative values (-1, -0.5, -10 as string) — documents that toFixed produces a leading minus sign.

Existing tests (whole numbers, long trailing decimals, numeric strings, non-finite input, zero, precision constant) are preserved unchanged.

Test Plan

The new cases follow the existing toFixed(XLM_DISPLAY_DECIMALS) behaviour of formatXlm:

  • formatXlm(1_000_000)'1000000.00' (no scientific notation)
  • formatXlm(0.0000001)'0.00' (rounds to 2 dp)
  • formatXlm(0.006)'0.01' (rounds up)
  • formatXlm(-1)'-1.00' (leading minus sign)

Run with: npx jest __tests__/lib/formatXlm.test.ts

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 formatXlm utility function edge cases

1 participant