diff options
author | Steve Klebanoff <steve@0xproject.com> | 2018-12-04 06:24:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 06:24:58 +0800 |
commit | 50df67e7511460f051f91785bb4384485077ef60 (patch) | |
tree | 3caa4fac28a2af99e7e7d0beff7a661d26f8665e /packages/instant/test/util | |
parent | f076cdb8329693e9d7351ec88d2ac01ad42a2a3a (diff) | |
parent | 91b0fd951708b0fff0733c2e1eed45a403f3cc73 (diff) | |
download | dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.gz dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.bz2 dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.lz dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.xz dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.zst dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.zip |
Merge pull request #1295 from 0xProject/feature/instant/rollbar-env
[instant] Rollbar
Diffstat (limited to 'packages/instant/test/util')
-rw-r--r-- | packages/instant/test/util/asset.test.ts | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/packages/instant/test/util/asset.test.ts b/packages/instant/test/util/asset.test.ts index 4229b24ed..fc4e4e2e4 100644 --- a/packages/instant/test/util/asset.test.ts +++ b/packages/instant/test/util/asset.test.ts @@ -1,6 +1,7 @@ +import { AssetBuyerError } from '@0x/asset-buyer'; import { AssetProxyId, ObjectMap } from '@0x/types'; -import { Asset, AssetMetaData, ERC20AssetMetaData, Network, ZeroExInstantError } from '../../src/types'; +import { Asset, AssetMetaData, ERC20Asset, ERC20AssetMetaData, Network, ZeroExInstantError } from '../../src/types'; import { assetUtils } from '../../src/util/asset'; const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; @@ -11,7 +12,7 @@ const ZRX_META_DATA: ERC20AssetMetaData = { decimals: 18, name: '0x', }; -const ZRX_ASSET: Asset = { +const ZRX_ASSET: ERC20Asset = { assetData: ZRX_ASSET_DATA, metaData: ZRX_META_DATA, }; @@ -45,4 +46,32 @@ describe('assetDataUtil', () => { ).toThrowError(ZeroExInstantError.AssetMetaDataNotAvailable); }); }); + describe('assetBuyerErrorMessage', () => { + it('should return message for InsufficientAssetLiquidity', () => { + const insufficientAssetError = new Error(AssetBuyerError.InsufficientAssetLiquidity); + expect(assetUtils.assetBuyerErrorMessage(ZRX_ASSET, insufficientAssetError)).toEqual( + 'Not enough ZRX available', + ); + }); + it('should return message for InsufficientAssetLiquidity', () => { + const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity); + expect(assetUtils.assetBuyerErrorMessage(ZRX_ASSET, insufficientZrxError)).toEqual( + 'Not enough ZRX available', + ); + }); + it('should message for StandardRelayerApiError', () => { + const standardRelayerError = new Error(AssetBuyerError.StandardRelayerApiError); + expect(assetUtils.assetBuyerErrorMessage(ZRX_ASSET, standardRelayerError)).toEqual( + 'ZRX is currently unavailable', + ); + }); + it('should return error for AssetUnavailable error', () => { + const assetUnavailableError = new Error( + `${AssetBuyerError.AssetUnavailable}: For assetData ${ZRX_ASSET_DATA}`, + ); + expect(assetUtils.assetBuyerErrorMessage(ZRX_ASSET, assetUnavailableError)).toEqual( + 'ZRX is currently unavailable', + ); + }); + }); }); |