@@ -4,7 +4,7 @@ import type { ReactNode } from 'react'
44import { createElement } from 'react'
55import { zeroAddress } from 'viem'
66import { beforeEach , describe , expect , it , vi } from 'vitest'
7- import type { Token } from '@/src/types/token'
7+ import { type Token , tokenSchema } from '@/src/types/token'
88import tokenListsCache , { updateTokenListsCache } from '@/src/utils/tokenListsCache'
99
1010vi . mock ( '@/src/utils/tokenListsCache' , ( ) => {
@@ -155,6 +155,29 @@ describe('fetchTokenList', () => {
155155 expect ( result . tokens ) . toEqual ( [ ] )
156156 warnSpy . mockRestore ( )
157157 } )
158+
159+ describe ( "'default' bundled token list" , ( ) => {
160+ it ( 'returns a non-empty tokens array' , async ( ) => {
161+ const result = await fetchTokenList ( 'default' )
162+
163+ expect ( result . tokens . length ) . toBeGreaterThan ( 0 )
164+ expect ( mockFetch ) . not . toHaveBeenCalled ( )
165+ } )
166+
167+ it ( 'every EVM token conforms to tokenSchema' , async ( ) => {
168+ const result = await fetchTokenList ( 'default' )
169+
170+ // The bundled list includes non-EVM tokens (e.g. Solana with base58 addresses)
171+ // alongside EVM tokens. Non-EVM entries are filtered out downstream by useTokenLists
172+ // via safeParse. Here we validate only the EVM-addressable subset.
173+ const evmTokens = result . tokens . filter ( ( { address } ) => / ^ 0 x [ a - f A - F 0 - 9 ] { 40 } $ / . test ( address ) )
174+ expect ( evmTokens . length ) . toBeGreaterThan ( 0 )
175+ for ( const token of evmTokens ) {
176+ expect ( ( ) => tokenSchema . parse ( token ) ) . not . toThrow ( )
177+ }
178+ expect ( mockFetch ) . not . toHaveBeenCalled ( )
179+ } )
180+ } )
158181} )
159182
160183describe ( 'useTokenLists' , ( ) => {
0 commit comments