aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/test
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-18 05:34:04 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-18 05:44:40 +0800
commit7b43cd14b305e3f01081e7ea7d0385966e4529be (patch)
treed84ae246c2bf8d3ba112c9fd0e781020aaf035f6 /packages/instant/test
parentf2f7598c0edcbef2a190595f835870c0b76af0cc (diff)
downloaddexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.tar
dexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.tar.gz
dexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.tar.bz2
dexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.tar.lz
dexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.tar.xz
dexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.tar.zst
dexon-sol-tools-7b43cd14b305e3f01081e7ea7d0385966e4529be.zip
error test
Diffstat (limited to 'packages/instant/test')
-rw-r--r--packages/instant/test/util/error.test.ts48
1 files changed, 48 insertions, 0 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..56f3a1e86
--- /dev/null
+++ b/packages/instant/test/util/error.test.ts
@@ -0,0 +1,48 @@
+import { AssetBuyerError } from '@0xproject/asset-buyer';
+
+import { errorUtil } from '../../src/util/error';
+
+const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
+
+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_DATA).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_DATA).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_DATA).message).toEqual(
+ 'ZRX is currently unavailable',
+ );
+ });
+ it('should return error for AssetUnavailable error', () => {
+ const assetUnavailableError = new Error(
+ `${AssetBuyerError.AssetUnavailable}: For assetData ${ZRX_ASSET_DATA}`,
+ );
+ expect(errorUtil.errorDescription(assetUnavailableError, ZRX_ASSET_DATA).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, 'xyz').message).toEqual(
+ 'This asset is currently unavailable',
+ );
+ });
+ });
+});