Skip to content

Write unit tests for formatting utilities #16

Description

@Code-Paragon

Problem

The src/utils/formatting.ts file handles critical BigNumber conversions (e.g., formatStroops), but has no test coverage to prove it protects against precision loss or invalid inputs.

Expected behavior

A test suite is added that explicitly passes edge-case inputs (large numbers, zero, NaN strings) into formatStroops, formatCurrency, and truncateAddress to verify robust behavior.

Files to update

  • src/utils/formatting.test.ts (create)

Project relevance

Mathematically guarantees that the UI will not crash or display incorrect balances when receiving unpredictable XDR values from the blockchain.

Acceptance criteria

  • Feature works as described
  • Tests are added or updated where needed
  • Documentation is updated where needed
  • Test asserts that formatStroops("invalid") safely returns "0.00"
  • No TypeScript, lint, test, or build errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions