From 6f3b2aca3b8ac72c65a6605138a5eb49782036de Mon Sep 17 00:00:00 2001 From: Geoff Doty Date: Wed, 6 Jun 2018 08:02:31 -0400 Subject: [PATCH] inversed if to remove extra else clauses --- dist/testit.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/dist/testit.js b/dist/testit.js index 73029ac..e5a7b58 100644 --- a/dist/testit.js +++ b/dist/testit.js @@ -1,4 +1,4 @@ -/*! Test.it v 0.6.1 | MIT | https://github.com/n2geoff/testit */ +/*! Test.it v 0.6.2 | MIT | https://github.com/n2geoff/testit */ (function (root, factory) { "use strict"; if (typeof module === "object" && module.exports) { @@ -55,39 +55,31 @@ "an": (type) => { if(['array'].indexOf(type) !== -1) { - if(val.constructor.name.toLowerCase() === 'array') { - return true; - } else { + if(val.constructor.name.toLowerCase() !== 'array') { throw new Error(`expected ${typeof val} to be an ${type}`); } + + return true; } - if(typeof val === type) { - return true; - } else { + if(typeof val !== type) { throw new Error(`expected ${typeof val} to be an ${type}`); } }, "like": (comp) => { - if(val == comp) { - return true; - } else { + if(val != comp) { throw new Error(`expected ${val} == ${comp}`); } } }, "equal": (comp) => { - if(val === comp) { - return true; - } else { + if(val !== comp) { throw new Error(`expected ${val} === ${comp}`); } }, "exist": () => { - if(val) { - return true; - } else { + if(!val) { throw new Error(`expected ${val} to be truthy`); } },