inversed if to remove extra else clauses

This commit is contained in:
Geoff Doty 2018-06-06 08:02:31 -04:00
parent 069466ac91
commit 6f3b2aca3b
1 changed files with 8 additions and 16 deletions

24
dist/testit.js vendored
View File

@ -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) { (function (root, factory) {
"use strict"; "use strict";
if (typeof module === "object" && module.exports) { if (typeof module === "object" && module.exports) {
@ -55,39 +55,31 @@
"an": (type) => { "an": (type) => {
if(['array'].indexOf(type) !== -1) { if(['array'].indexOf(type) !== -1) {
if(val.constructor.name.toLowerCase() === 'array') { if(val.constructor.name.toLowerCase() !== 'array') {
return true;
} else {
throw new Error(`expected ${typeof val} to be an ${type}`); throw new Error(`expected ${typeof val} to be an ${type}`);
} }
return true;
} }
if(typeof val === type) { if(typeof val !== type) {
return true;
} else {
throw new Error(`expected ${typeof val} to be an ${type}`); throw new Error(`expected ${typeof val} to be an ${type}`);
} }
}, },
"like": (comp) => { "like": (comp) => {
if(val == comp) { if(val != comp) {
return true;
} else {
throw new Error(`expected ${val} == ${comp}`); throw new Error(`expected ${val} == ${comp}`);
} }
} }
}, },
"equal": (comp) => { "equal": (comp) => {
if(val === comp) { if(val !== comp) {
return true;
} else {
throw new Error(`expected ${val} === ${comp}`); throw new Error(`expected ${val} === ${comp}`);
} }
}, },
"exist": () => { "exist": () => {
if(val) { if(!val) {
return true;
} else {
throw new Error(`expected ${val} to be truthy`); throw new Error(`expected ${val} to be truthy`);
} }
}, },