Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yogurtandjam committed Oct 14, 2024
1 parent 3f05f3d commit 8f319ae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/constants/__test__/cctp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
getMapOfHighestFeeTokensByChainId,
getMapOfLowestFeeTokensByChainId,
getMapOfLowestFeeTokensByDenom,
isTokenCctp,
} from '@/constants/cctp';

import cctpTokens from '../../../public/configs/cctp.json';
import { TransferType } from '../abacus';

describe('getLowestFeeChainNames', () => {
Expand Down Expand Up @@ -252,3 +254,39 @@ describe('getMapOfHighestFeeTokensByChainId', () => {
});
});
});

describe('isTokenCctp', () => {
const getTestAssetWithDenom = (denom: string) => ({
denom,
chainID: '1',
originDenom: denom,
originChainID: '1',
trace: 'test-trace',
isCW20: false,
isEVM: true,
isSVM: false,
symbol: 'test-symbol',
name: 'test-name',
logoURI: 'test-logoURI',
decimals: 10,
tokenContract: 'test-contract',
description: 'test-description',
coingeckoID: 'test-coingeckoID',
recommendedSymbol: 'test-recommendedSymbol',
});
it('returns true for cctp token', () => {
const denom = cctpTokens[0].tokenAddress;
const asset = getTestAssetWithDenom(denom);
expect(isTokenCctp(asset)).toBe(true);
});
it('returns true for cctp token case insensitive', () => {
const denom = cctpTokens[0].tokenAddress.toLowerCase();
const asset = getTestAssetWithDenom(denom);
expect(isTokenCctp(asset)).toBe(true);
});
it('returns false for non-cctp tokens', () => {
const denom = 'non-cctp-denom';
const asset = getTestAssetWithDenom(denom);
expect(isTokenCctp(asset)).toBe(false);
});
});
2 changes: 1 addition & 1 deletion src/constants/cctp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ export const isTokenCctp = (token: Asset | undefined) => {

const isDenomCctp = (denom: string | undefined) => {
if (!denom) return false;
return cctpTokensByDenom[denom.toUpperCase()];
return Boolean(cctpTokensByDenom[denom.toUpperCase()]);
};

0 comments on commit 8f319ae

Please sign in to comment.