aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/test
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-19 06:42:33 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-19 06:42:33 +0800
commitc87e68f833a2d8a87846d70a9d4a727b46323eea (patch)
treeeb40dc12694baf607a373f427f32dbd9393ac72f /packages/instant/test
parenta764dfa789ba44e519371b4a1e4569db7f551fb7 (diff)
parent65d85ca5008fe0c307506b388d6ace858122f8ad (diff)
downloaddexon-sol-tools-c87e68f833a2d8a87846d70a9d4a727b46323eea.tar.gz
dexon-sol-tools-c87e68f833a2d8a87846d70a9d4a727b46323eea.tar.zst
dexon-sol-tools-c87e68f833a2d8a87846d70a9d4a727b46323eea.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/beta-render-et-al
Diffstat (limited to 'packages/instant/test')
-rw-r--r--packages/instant/test/util/error.test.ts56
-rw-r--r--packages/instant/test/util/format.test.ts4
2 files changed, 58 insertions, 2 deletions
diff --git a/packages/instant/test/util/error.test.ts b/packages/instant/test/util/error.test.ts
new file mode 100644
index 000000000..b009db91a
--- /dev/null
+++ b/packages/instant/test/util/error.test.ts
@@ -0,0 +1,56 @@
+import { AssetBuyerError } from '@0x/asset-buyer';
+import { AssetProxyId } from '@0x/types';
+
+import { Asset } from '../../src/types';
+import { errorUtil } from '../../src/util/error';
+
+const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
+const ZRX_ASSET: Asset = {
+ assetData: ZRX_ASSET_DATA,
+ metaData: {
+ assetProxyId: AssetProxyId.ERC20,
+ symbol: 'zrx',
+ decimals: 18,
+ },
+};
+
+describe('errorUtil', () => {
+ describe('errorFlasher', () => {
+ it('should return error and asset name for InsufficientAssetLiquidity', () => {
+ const insufficientAssetError = new Error(AssetBuyerError.InsufficientAssetLiquidity);
+ expect(errorUtil.errorDescription(insufficientAssetError, ZRX_ASSET).message).toEqual(
+ 'Not enough ZRX available',
+ );
+ });
+ it('should return error default name for InsufficientAssetLiquidity', () => {
+ const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity);
+ expect(errorUtil.errorDescription(insufficientZrxError).message).toEqual(
+ 'Not enough of this asset available',
+ );
+ });
+ it('should return asset name for InsufficientAssetLiquidity', () => {
+ const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity);
+ expect(errorUtil.errorDescription(insufficientZrxError, ZRX_ASSET).message).toEqual(
+ 'Not enough ZRX available',
+ );
+ });
+ it('should return unavailable error and asset name for StandardRelayerApiError', () => {
+ const standardRelayerError = new Error(AssetBuyerError.StandardRelayerApiError);
+ expect(errorUtil.errorDescription(standardRelayerError, ZRX_ASSET).message).toEqual(
+ 'ZRX is currently unavailable',
+ );
+ });
+ it('should return error for AssetUnavailable error', () => {
+ const assetUnavailableError = new Error(`${AssetBuyerError.AssetUnavailable}: For assetData ${ZRX_ASSET}`);
+ expect(errorUtil.errorDescription(assetUnavailableError, ZRX_ASSET).message).toEqual(
+ 'ZRX is currently unavailable',
+ );
+ });
+ it('should return default for AssetUnavailable error', () => {
+ const assetUnavailableError = new Error(`${AssetBuyerError.AssetUnavailable}: For assetData xyz`);
+ expect(errorUtil.errorDescription(assetUnavailableError, ZRX_ASSET).message).toEqual(
+ 'This asset is currently unavailable',
+ );
+ });
+ });
+});
diff --git a/packages/instant/test/util/format.test.ts b/packages/instant/test/util/format.test.ts
index 073b86b19..141df9275 100644
--- a/packages/instant/test/util/format.test.ts
+++ b/packages/instant/test/util/format.test.ts
@@ -1,5 +1,5 @@
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import { ethDecimals } from '../../src/constants';
import { format } from '../../src/util/format';