From 2117b4e0c87df277f5e8df54e8df922bdf19c298 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 25 May 2017 12:23:13 +0200 Subject: Use expect.to.throw --- test/0x.js.ts | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/test/0x.js.ts b/test/0x.js.ts index 2c4471e0f..09266018b 100644 --- a/test/0x.js.ts +++ b/test/0x.js.ts @@ -21,12 +21,7 @@ describe('ZeroEx library', () => { r: signature.r, s: signature.s, }; - try { - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - throw new Error('isValidSignature should have thrown'); - } catch (err) { - // continue - } + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); it('r lacks 0x prefix', () => { const malformedR = signature.r.replace('0x', ''); @@ -35,12 +30,7 @@ describe('ZeroEx library', () => { r: malformedR, s: signature.s, }; - try { - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - throw new Error('isValidSignature should have thrown'); - } catch (err) { - // continue - } + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); it('r is too short', () => { const malformedR = signature.r.substr(10); @@ -49,12 +39,7 @@ describe('ZeroEx library', () => { r: malformedR, s: signature.s.replace('0', 'z'), }; - try { - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - throw new Error('isValidSignature should have thrown'); - } catch (err) { - // continue - } + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); it('s is not hex', () => { const malformedS = signature.s.replace('0', 'z'); @@ -63,12 +48,7 @@ describe('ZeroEx library', () => { r: signature.r, s: malformedS, }; - try { - const isValid = ZeroEx.isValidSignature(data, malformedSignature, address); - throw new Error('isValidSignature should have thrown'); - } catch (err) { - // continue - } + expect(() => ZeroEx.isValidSignature(data, malformedSignature, address)).to.throw(); }); }); it('should return false if the data doesn\'t pertain to the signature & address', () => { -- cgit v1.2.3