mirror of https://github.com/n2geoff/testit.git
inversed if to remove extra else clauses
This commit is contained in:
parent
069466ac91
commit
6f3b2aca3b
|
@ -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`);
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue