blob: d746316f84851470c5da5fa654e82872b04dad61 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { BigNumber } from '@0x/utils';
import { InsufficientAssetLiquidityError } from '../../src/errors';
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);
if (expectedAmountAvailableToFill) {
expect(e.amountAvailableToFill).to.be.bignumber.equal(expectedAmountAvailableToFill);
} else {
expect(e.amountAvailableToFill).to.be.undefined();
}
}
expect(errorThrown).to.be.true();
},
};
|