Skip to content

Commit c0b877d

Browse files
Add tests for isTronSpecialAsset
1 parent 98e0073 commit c0b877d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

app/core/Multichain/test/utils.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
getAddressUrl,
2626
getTransactionUrl,
2727
isTronAddress,
28+
isTronSpecialAsset,
2829
} from '../utils';
2930
import { KeyringTypes } from '@metamask/keyring-controller';
3031
import { toChecksumHexAddress } from '@metamask/controller-utils';
@@ -525,4 +526,28 @@ describe('MultiChain utils', () => {
525526
});
526527
});
527528
});
529+
530+
describe('isTronSpecialAsset', () => {
531+
it('returns false for non-Tron chain ID', () => {
532+
expect(isTronSpecialAsset('eip155:1', 'TRX')).toBe(false);
533+
expect(isTronSpecialAsset(undefined, 'TRX')).toBe(false);
534+
});
535+
536+
it('returns true if symbol is falsy', () => {
537+
expect(isTronSpecialAsset('tron:mainnet', '')).toBe(true);
538+
expect(isTronSpecialAsset('tron:mainnet', undefined)).toBe(true);
539+
});
540+
541+
it('returns true for known special assets', () => {
542+
expect(isTronSpecialAsset('tron:mainnet', 'energy')).toBe(true);
543+
expect(isTronSpecialAsset('tron:mainnet', 'bandwidth')).toBe(true);
544+
expect(isTronSpecialAsset('tron:mainnet', 'trx-in-lock-period')).toBe(true);
545+
});
546+
547+
it('returns false for valid TRON tokens with normal symbols', () => {
548+
expect(isTronSpecialAsset('tron:mainnet', 'TRX')).toBe(false);
549+
expect(isTronSpecialAsset('tron:mainnet', 'USDT')).toBe(false);
550+
expect(isTronSpecialAsset('tron:mainnet', 'BTT')).toBe(false);
551+
});
552+
});
528553
});

0 commit comments

Comments
 (0)