diff options
Diffstat (limited to 'packages/asset-buyer/test/utils/test_helpers.ts')
-rw-r--r-- | packages/asset-buyer/test/utils/test_helpers.ts | 26 |
1 files changed, 26 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..9c7c244af --- /dev/null +++ b/packages/asset-buyer/test/utils/test_helpers.ts @@ -0,0 +1,26 @@ +import { BigNumber } from '@0x/utils'; + +import { InsufficientAssetLiquidityError } from '../../src/errors'; + +export const testHelpers = { + expectInsufficientLiquidityError: ( + expect: Chai.ExpectStatic, + functionWhichTriggersError: () => void, + expectedAmountAvailableToFill?: BigNumber, + ): void => { + let wasErrorThrown = false; + try { + functionWhichTriggersError(); + } catch (e) { + wasErrorThrown = true; + expect(e).to.be.instanceOf(InsufficientAssetLiquidityError); + if (expectedAmountAvailableToFill) { + expect(e.amountAvailableToFill).to.be.bignumber.equal(expectedAmountAvailableToFill); + } else { + expect(e.amountAvailableToFill).to.be.undefined(); + } + } + + expect(wasErrorThrown).to.be.true(); + }, +}; |