@ethereum-waffle/chai
Version:
A sweet set of chai matchers for your blockchain testing needs.
12 lines (11 loc) • 527 B
text/typescript
export function supportProperHex(Assertion: Chai.AssertionStatic) {
Assertion.addMethod('properHex', function (this: any, length: number) {
const subject = this._obj;
const regexp = new RegExp(`^0x[0-9-a-fA-F]{${length}}$`);
this.assert(regexp.test(subject),
`Expected "${subject}" to be a proper hex of length ${length}`,
`Expected "${subject}" not to be a proper hex of length ${length}, but it was`,
'proper address (eg.: 0x1234567890123456789012345678901234567890)',
subject);
});
}