Skip to content

useTransactionQuery has no tests: query state and refetch logic is uncovered #877

Description

@nanaf6203-bit

useTransactionQuery has no tests: query state and refetch logic is uncovered

Labels / Complexity: testing · Medium Complexity — Medium

Problem

useTransactionQuery (src/hooks/useTransactionQuery.ts) wraps transaction data fetching with loading/error/refetch state. It has no tests. A regression that drops the error state or breaks refetch ships silently in every screen that lists transactions.

Why this is architecturally hard

  1. Query state is the test design. Tests must pin loading → data, loading → error, and refetch transitions with a stubbed fetcher.
  2. The data source is the mock (i add sample readme #9). Tests written now should assert against the current fetch contract so the mock-to-real migration cannot silently change the hook's behavior.

Acceptance criteria

  • Tests cover loading, success, error, and refetch states with a stubbed fetcher.
  • Tests run in CI via npm test.

Out of scope

The transactions API mock (#9); other hooks.

Getting started

  • src/hooks/useTransactionQuery.ts — the hook
  • src/hooks/__tests__/useToast.test.ts — the pattern

Commands: npm test.

Good first files to read: src/hooks/useTransactionQuery.ts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions