aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/test/util/asset.test.ts
blob: 9ca4a3d522d4ffadac183e48bbda9c278ad9a71e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { AssetProxyId } from '@0x/types';

import { Asset } from '../../src/types';
import { assetUtils } from '../../src/util/asset';

const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
const ZRX_ASSET: Asset = {
    assetData: ZRX_ASSET_DATA,
    metaData: {
        assetProxyId: AssetProxyId.ERC20,
        symbol: 'zrx',
        decimals: 18,
    },
};

describe('assetDataUtil', () => {
    describe('bestNameForAsset', () => {
        it('should return default string if assetData is undefined', () => {
            expect(assetUtils.bestNameForAsset(undefined, 'xyz')).toEqual('xyz');
        });
        it('should return ZRX for ZRX assetData', () => {
            expect(assetUtils.bestNameForAsset(ZRX_ASSET, 'mah default')).toEqual('ZRX');
        });
    });
});