Throw a better error message when taker is null|undefined or anything but not a string

This commit is contained in:
Leonid Logvinov
2017-12-19 16:22:57 +01:00
parent 1316a2dd2a
commit 75f637bd75
6 changed files with 87 additions and 24 deletions

View File

@@ -152,6 +152,15 @@ describe('ZeroEx library', () => {
const orderHash = ZeroEx.getOrderHashHex(order);
expect(orderHash).to.be.equal(expectedOrderHash);
});
it('throws a readable error message if taker format is invalid', async () => {
const orderWithInvalidtakerFormat = {
...order,
taker: null as any as string,
};
// tslint:disable-next-line:max-line-length
const expectedErrorMessage = 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
expect(() => ZeroEx.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
});
});
describe('#signOrderHashAsync', () => {
let stubs: Sinon.SinonStub[] = [];