aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test/utils/test_helpers.ts
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-14 07:16:51 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-15 07:34:45 +0800
commitc6c45095a8511814db6aa33e39794ae60debad8b (patch)
tree708189f5ec03707c2954725db150788026fc3b1f /packages/asset-buyer/test/utils/test_helpers.ts
parent6d45beccad44e86ddd692d0cf54c09c29c5d9daf (diff)
downloaddexon-0x-contracts-c6c45095a8511814db6aa33e39794ae60debad8b.tar.gz
dexon-0x-contracts-c6c45095a8511814db6aa33e39794ae60debad8b.tar.zst
dexon-0x-contracts-c6c45095a8511814db6aa33e39794ae60debad8b.zip
feat(asset-buyer): Custom InsufficientAssetLiquidityError error
BREAKING CHANGE: A custom InsufficientAssetLiquidityError error is now raised when there is insufficient liquidity
Diffstat (limited to 'packages/asset-buyer/test/utils/test_helpers.ts')
-rw-r--r--packages/asset-buyer/test/utils/test_helpers.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/asset-buyer/test/utils/test_helpers.ts b/packages/asset-buyer/test/utils/test_helpers.ts
new file mode 100644
index 000000000..fd1313ac8
--- /dev/null
+++ b/packages/asset-buyer/test/utils/test_helpers.ts
@@ -0,0 +1,22 @@
+import { BigNumber } from '@0x/utils';
+
+import { InsufficientAssetLiquidityError } from '../../src/types';
+
+export const testHelpers = {
+ expectInsufficientLiquidityError: (
+ expect: Chai.ExpectStatic,
+ functionWhichTriggersError: () => void,
+ expectedNumAvailable: BigNumber,
+ ): void => {
+ let errorThrown = false;
+ try {
+ functionWhichTriggersError();
+ } catch (e) {
+ errorThrown = true;
+ expect(e).to.be.instanceOf(InsufficientAssetLiquidityError);
+ expect(e.numAssetsAvailable).to.be.bignumber.equal(expectedNumAvailable);
+ }
+
+ expect(errorThrown).to.be.true();
+ },
+};