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) {
"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`);
}
},