Skip to content

portfolioService has no tests: holdings and gas-balance mapping are uncovered #930

Description

@nanaf6203-bit

portfolioService has no tests: holdings and gas-balance mapping are uncovered

Labels / Complexity: testing · Medium Complexity — Medium

Problem

src/lib/portfolioService.ts returns token holdings and gas balances — currently from MOCK_TOKEN_HOLDINGS/MOCK_GAS_BALANCES (#20). It has no tests. The service's shape is the contract the portfolio store and dashboard consume, and it is completely unpinned before the mock is replaced.

Why this is architecturally hard

  1. Mapping is the test design. The service maps raw balance data into the UI shapes; tests must pin the mapping so the mock-to-real migration (issue14 #20) cannot change what the dashboard receives.
  2. Fallback behavior matters. The current fallback (MOCK_TOKEN_HOLDINGS[chainId] || []) needs a pinned replacement contract for unknown chains.

Acceptance criteria

  • Tests cover the mapping for known/unknown chains and the empty state.
  • Tests run in CI via npm test.

Out of scope

The portfolio mock migration (#20); the store.

Getting started

  • src/lib/portfolioService.ts — the service
  • src/lib/__tests__/ — existing lib test patterns

Commands: npm test.

Good first files to read: src/lib/portfolioService.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions