aboutsummaryrefslogblamecommitdiffstats
path: root/packages/asset-buyer/test/utils/test_helpers.ts
blob: 9c7c244af04ed5edb2c7caf45d0bdea26761f9aa (plain) (tree)
1
2
3
4
5
6
7
8
9

                                      
                                                                   




                                               
                                                  
                
                                   


                                         
                                  
                                                                        




                                                                                                     

         
                                            

      
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();
    },
};