aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test/utils/test_helpers.ts
diff options
context:
space:
mode:
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();
+ },
+};