Skip to content

test: add coverage for fetchTokenList('default') bundled token path#447

Open
gabitoesmiapodo wants to merge 4 commits intodevelopfrom
chore/438
Open

test: add coverage for fetchTokenList('default') bundled token path#447
gabitoesmiapodo wants to merge 4 commits intodevelopfrom
chore/438

Conversation

@gabitoesmiapodo
Copy link
Copy Markdown
Collaborator

@gabitoesmiapodo gabitoesmiapodo commented Apr 7, 2026

Summary

fetchTokenList('default') -- the code path returning the bundled @uniswap/default-token-list -- had zero test coverage. A major version bump (v13 to v18 in #434) could silently break the data shape with no automated detection.

Closes #438

Changes

  • Added tokenSchema to the imports in src/hooks/useTokenLists.test.ts
  • Added a 'default' bundled token list describe block with two tests for fetchTokenList('default')
  • Added a comment in useTokenLists.ts at the safeParse filter explaining why non-EVM tokens (e.g. Solana) are dropped and that supporting them requires broader changes

Acceptance criteria

  • fetchTokenList('default') is called in a test without mocking @uniswap/default-token-list away
  • The test asserts the result has a non-empty tokens array and that entries conform to tokenSchema
  • Existing tests remain unaffected

Test plan

pnpm test src/hooks/useTokenLists.test.ts  # 11 tests pass (2 new)
pnpm test                                  # 172 tests pass
pnpm lint                                  # clean

Note: the v18 bundled list includes 173 Solana tokens with base58 addresses that fail the EVM address regex. The schema test filters to ^0x[a-fA-F0-9]{40}$ addresses before calling tokenSchema.parse(), mirroring how useTokenLists filters them out downstream via safeParse.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Test that the bundled @uniswap/default-token-list returns a non-empty
tokens array and that all EVM-addressable entries conform to tokenSchema.

The v18 list also includes Solana tokens (base58 addresses) which are
expected to fail the EVM address regex and are filtered out downstream
by useTokenLists via safeParse.

Closes #438
Copilot AI review requested due to automatic review settings April 7, 2026 14:37
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components.dappbooster Ready Ready Preview, Comment Apr 7, 2026 3:47pm
demo.dappbooster Ready Ready Preview, Comment Apr 7, 2026 3:47pm
docs.dappbooster Ready Ready Preview, Comment Apr 7, 2026 3:47pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds test coverage for the previously-uncovered fetchTokenList('default') path that returns the bundled @uniswap/default-token-list, helping ensure the app’s default-token boot path is validated against expected shape/contents.

Changes:

  • Import tokenSchema into src/hooks/useTokenLists.test.ts for schema validation.
  • Add a test asserting the bundled default list returns a non-empty tokens array.
  • Add a test validating all EVM-addressable entries from the bundled list conform to tokenSchema.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Adds a comment explaining that tokenSchema's EVM address format drops
Solana and other non-EVM tokens from the bundled list, and that adding
non-EVM support requires broader changes.

Also renames the related test for clarity.
- Remove redundant Array.isArray assertion (length check is sufficient)
- Assert mockFetch was not called to make the contract of the 'default'
  path explicit and guard against future regressions
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add test coverage for fetchTokenList('default') bundled token path

2 participants