aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test/utils/test_helpers.ts
blob: b9990679218de6de70e66bc9c38bd57fd2350fcd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { BigNumber } from '@0x/utils';

import { InsufficientAssetLiquidityError } from '../../src/types';

export const testHelpers = {
    expectInsufficientLiquidityError: (
        expect: Chai.ExpectStatic,
        functionWhichTriggersError: () => void,
        expectedAmountAvailableToFill: BigNumber,
    ): void => {
        let errorThrown = false;
        try {
            functionWhichTriggersError();
        } catch (e) {
            errorThrown = true;
            expect(e).to.be.instanceOf(InsufficientAssetLiquidityError);
            expect(e.amountAvailableToFill).to.be.bignumber.equal(expectedAmountAvailableToFill);
        }

        expect(errorThrown).to.be.true();
    },
};