Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/api-mocking/mock-responses/defaults/token-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import { TOKEN_API_TOKENS_RESPONSE } from '../token-api-responses.ts';
const tokenListRegex =
/^https:\/\/token\.api\.cx\.metamask\.io\/tokens\/\d+\?.*$/;

// Single-token metadata: /token/{chainId}?address=0x...
// The controller fetches this for any token the app encounters (swap quotes,
// bridge destinations, etc.). Without a default mock every test that triggers
// the request must add its own — and missing ones cause validateLiveRequests
// failures. Return a minimal valid response so tests don't break.
const singleTokenMetadataRegex =
/^https:\/\/token\.api\.cx\.metamask\.io\/token\/\d+\?address=0x[a-fA-F0-9]+/;

const tokenAssetsRegex =
/^https:\/\/token\.api\.cx\.metamask\.io\/assets\?assetIds=.*&includeTokenSecurityData=true$/;

Expand All @@ -24,6 +32,19 @@ export const TOKEN_API_MOCKS: MockEventsObject = {
responseCode: 200,
response: TOKEN_API_TOKENS_RESPONSE,
},
{
urlEndpoint: singleTokenMetadataRegex,
responseCode: 200,
response: {
address: '0x0000000000000000000000000000000000000000',
symbol: 'TOKEN',
decimals: 18,
occurrences: 1,
aggregators: [],
name: 'Mock Token',
iconUrl: '',
},
},
{
urlEndpoint: tokenAssetsRegex,
responseCode: 200,
Expand Down
Loading