mirror of https://github.com/n2geoff/testit.git
				
				
				
			inversed if to remove extra else clauses
This commit is contained in:
		
							parent
							
								
									22a49b4a75
								
							
						
					
					
						commit
						337033436d
					
				| 
						 | 
				
			
			@ -1,2 +1,2 @@
 | 
			
		|||
/*! Test.it v 0.6.1 | MIT | https://github.com/n2geoff/testit */
 | 
			
		||||
!function(t,e){"use strict";"object"==typeof module&&module.exports?module.exports=e(t.test):t.test=e(t.test)}(this,function(){"use strict";const t={_tests:{},run:function(t){let e=this._tests,r=[],o=[];return Object.keys(e).forEach(function(t){let n=e[t];try{n(),o.push(`\n+ ${t}`)}catch(e){r.push(`\n- ${t}`),console.error(e)}}),"function"==typeof t?t({pass:o,fail:r}):(console.log(...o,...r),console.log(`\n# tests ${r.length+o.length} pass ${o.length} fail ${r.length}`),!r.length)},it:function(t){return this._tests=t,this},expects:e=>({to:{be:{a:r=>t.expects(e).to.be.an(r),an:t=>{if(-1!==["array"].indexOf(t)){if("array"===e.constructor.name.toLowerCase())return!0;throw new Error(`expected ${typeof e} to be an ${t}`)}if(typeof e===t)return!0;throw new Error(`expected ${typeof e} to be an ${t}`)},like:t=>{if(e==t)return!0;throw new Error(`expected ${e} == ${t}`)}},equal:t=>{if(e===t)return!0;throw new Error(`expected ${e} === ${t}`)},exist:()=>{if(e)return!0;throw new Error(`expected ${e} to be truthy`)},pass:()=>!0,fail:t=>{throw new Error(t)}}})};return t});
 | 
			
		||||
/*! Test.it v 0.6.2 | MIT | https://github.com/n2geoff/testit */
 | 
			
		||||
!function(t,e){"use strict";"object"==typeof module&&module.exports?module.exports=e(t.test):t.test=e(t.test)}(this,function(){"use strict";const t={_tests:{},run:function(t){let e=this._tests,r=[],o=[];return Object.keys(e).forEach(function(t){let n=e[t];try{n(),o.push(`\n+ ${t}`)}catch(e){r.push(`\n- ${t}`),console.error(e)}}),"function"==typeof t?t({pass:o,fail:r}):(console.log(...o,...r),console.log(`\n# tests ${r.length+o.length} pass ${o.length} fail ${r.length}`),!r.length)},it:function(t){return this._tests=t,this},expects:e=>({to:{be:{a:r=>t.expects(e).to.be.an(r),an:t=>{if(-1!==["array"].indexOf(t)){if("array"!==e.constructor.name.toLowerCase())throw new Error(`expected ${typeof e} to be an ${t}`);return!0}if(typeof e!==t)throw new Error(`expected ${typeof e} to be an ${t}`)},like:t=>{if(e!=t)throw new Error(`expected ${e} == ${t}`)}},equal:t=>{if(e!==t)throw new Error(`expected ${e} === ${t}`)},exist:()=>{if(!e)throw new Error(`expected ${e} to be truthy`)},pass:()=>!0,fail:t=>{throw new Error(t)}}})};return t});
 | 
			
		||||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
    // support  browser & commonjs
 | 
			
		||||
| 
						 | 
				
			
			@ -60,39 +60,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