mirror of https://github.com/n2geoff/testit.git
bump version
This commit is contained in:
parent
7444e0abcc
commit
c99bd20059
|
@ -1,6 +1,7 @@
|
||||||
/*! Test.it v 0.9.0 | MIT | https://github.com/n2geoff/testit */
|
/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */
|
||||||
const test = {
|
const test = {
|
||||||
"log": console.log,
|
"log": console.log,
|
||||||
|
"version": "v1.0.0",
|
||||||
"_tests": {},
|
"_tests": {},
|
||||||
"run": function run(errors, next) {
|
"run": function run(errors, next) {
|
||||||
if(typeof errors !== "boolean") {
|
if(typeof errors !== "boolean") {
|
||||||
|
@ -43,46 +44,14 @@ const test = {
|
||||||
this._tests = tests;
|
this._tests = tests;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
"expects": function expects(val) {
|
"assert": (expression, msg) => {
|
||||||
return {
|
try {
|
||||||
"to": {
|
if(!expression) {
|
||||||
"be": {
|
throw new Error(msg || "Assertion Failed");
|
||||||
"a": (type) => { return test.expects(val).to.be.an(type); },
|
|
||||||
"an": (type) => {
|
|
||||||
|
|
||||||
if(["array"].indexOf(type) !== -1) {
|
|
||||||
if(val.constructor.name.toLowerCase() !== "array") {
|
|
||||||
throw new Error(`expected ${typeof val} to be an ${type}`);
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
return true;
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof val !== type) {
|
|
||||||
throw new Error(`expected ${typeof val} to be an ${type}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ok": () => { return test.expects(val).to.exist(); },
|
|
||||||
"like": (comp) => {
|
|
||||||
if(val != comp) {
|
|
||||||
throw new Error(`expected ${val} == ${comp}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"equal": (comp) => {
|
|
||||||
if(val !== comp) {
|
|
||||||
throw new Error(`expected ${val} === ${comp}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"exist": () => {
|
|
||||||
if(!val) {
|
|
||||||
throw new Error(`expected ${val} to be truthy`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pass": () => { return true; },
|
|
||||||
"fail": (msg) => { throw new Error(msg); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
const test={log:console.log,_tests:{},run:function(t,e){"boolean"!=typeof t&&(e=t,t=!0);let r=this._tests||[],o=[],n=[];return Object.keys(r).forEach(e=>{let s=r[e];try{s(),n.push(`\n+OK ${e}`)}catch(r){t?o.push(`\n-ERR ${e} \n --- \n ${r.stack} \n ---`):o.push(`\n-ERR ${e}`)}}),"function"==typeof e?e({pass:n,fail:o}):(test.log(...n,...o),test.log(`\n# tests ${o.length+n.length} pass ${n.length} fail ${o.length}`),!o.length)},it:function(t){return this._tests=t,this},expects:function(t){return{to:{be:{a:e=>test.expects(t).to.be.an(e),an:e=>{if(-1!==["array"].indexOf(e)){if("array"!==t.constructor.name.toLowerCase())throw new Error(`expected ${typeof t} to be an ${e}`);return!0}if(typeof t!==e)throw new Error(`expected ${typeof t} to be an ${e}`)},ok:()=>test.expects(t).to.exist(),like:e=>{if(t!=e)throw new Error(`expected ${t} == ${e}`)}},equal:e=>{if(t!==e)throw new Error(`expected ${t} === ${e}`)},exist:()=>{if(!t)throw new Error(`expected ${t} to be truthy`)},pass:()=>!0,fail:t=>{throw new Error(t)}}}}};export default test;
|
const test={log:console.log,version:"v1.0.0",_tests:{},run:function(t,e){"boolean"!=typeof t&&(e=t,t=!0);let s=this._tests||[],n=[],o=[];return Object.keys(s).forEach(e=>{let r=s[e];try{r(),o.push(`\n+OK ${e}`)}catch(s){t?n.push(`\n-ERR ${e} \n --- \n ${s.stack} \n ---`):n.push(`\n-ERR ${e}`)}}),"function"==typeof e?e({pass:o,fail:n}):(test.log(...o,...n),test.log(`\n# tests ${n.length+o.length} pass ${o.length} fail ${n.length}`),!n.length)},it:function(t){return this._tests=t,this},assert:(t,e)=>{try{if(!t)throw new Error(e||"Assertion Failed")}catch(t){throw new Error(e)}}};export default test;
|
|
@ -4,9 +4,10 @@
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.umd = factory());
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.umd = factory());
|
||||||
}(this, (function () { 'use strict';
|
}(this, (function () { 'use strict';
|
||||||
|
|
||||||
/*! Test.it v 0.9.0 | MIT | https://github.com/n2geoff/testit */
|
/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */
|
||||||
const test = {
|
const test = {
|
||||||
"log": console.log,
|
"log": console.log,
|
||||||
|
"version": "v1.0.0",
|
||||||
"_tests": {},
|
"_tests": {},
|
||||||
"run": function run(errors, next) {
|
"run": function run(errors, next) {
|
||||||
if(typeof errors !== "boolean") {
|
if(typeof errors !== "boolean") {
|
||||||
|
@ -49,46 +50,14 @@
|
||||||
this._tests = tests;
|
this._tests = tests;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
"expects": function expects(val) {
|
"assert": (expression, msg) => {
|
||||||
return {
|
try {
|
||||||
"to": {
|
if(!expression) {
|
||||||
"be": {
|
throw new Error(msg || "Assertion Failed");
|
||||||
"a": (type) => { return test.expects(val).to.be.an(type); },
|
|
||||||
"an": (type) => {
|
|
||||||
|
|
||||||
if(["array"].indexOf(type) !== -1) {
|
|
||||||
if(val.constructor.name.toLowerCase() !== "array") {
|
|
||||||
throw new Error(`expected ${typeof val} to be an ${type}`);
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
return true;
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof val !== type) {
|
|
||||||
throw new Error(`expected ${typeof val} to be an ${type}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ok": () => { return test.expects(val).to.exist(); },
|
|
||||||
"like": (comp) => {
|
|
||||||
if(val != comp) {
|
|
||||||
throw new Error(`expected ${val} == ${comp}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"equal": (comp) => {
|
|
||||||
if(val !== comp) {
|
|
||||||
throw new Error(`expected ${val} === ${comp}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"exist": () => {
|
|
||||||
if(!val) {
|
|
||||||
throw new Error(`expected ${val} to be truthy`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pass": () => { return true; },
|
|
||||||
"fail": (msg) => { throw new Error(msg); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define("umd",t):(e="undefined"!=typeof globalThis?globalThis:e||self).umd=t()}(this,function(){"use strict";const e={log:console.log,_tests:{},run:function(t,o){"boolean"!=typeof t&&(o=t,t=!0);let n=this._tests||[],r=[],s=[];return Object.keys(n).forEach(e=>{let o=n[e];try{o(),s.push(`\n+OK ${e}`)}catch(o){t?r.push(`\n-ERR ${e} \n --- \n ${o.stack} \n ---`):r.push(`\n-ERR ${e}`)}}),"function"==typeof o?o({pass:s,fail:r}):(e.log(...s,...r),e.log(`\n# tests ${r.length+s.length} pass ${s.length} fail ${r.length}`),!r.length)},it:function(e){return this._tests=e,this},expects:function(t){return{to:{be:{a:o=>e.expects(t).to.be.an(o),an:e=>{if(-1!==["array"].indexOf(e)){if("array"!==t.constructor.name.toLowerCase())throw new Error(`expected ${typeof t} to be an ${e}`);return!0}if(typeof t!==e)throw new Error(`expected ${typeof t} to be an ${e}`)},ok:()=>e.expects(t).to.exist(),like:e=>{if(t!=e)throw new Error(`expected ${t} == ${e}`)}},equal:e=>{if(t!==e)throw new Error(`expected ${t} === ${e}`)},exist:()=>{if(!t)throw new Error(`expected ${t} to be truthy`)},pass:()=>!0,fail:e=>{throw new Error(e)}}}}};return e});
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("umd",e):(t="undefined"!=typeof globalThis?globalThis:t||self).umd=e()}(this,function(){"use strict";const t={log:console.log,version:"v1.0.0",_tests:{},run:function(e,n){"boolean"!=typeof e&&(n=e,e=!0);let o=this._tests||[],s=[],i=[];return Object.keys(o).forEach(t=>{let n=o[t];try{n(),i.push(`\n+OK ${t}`)}catch(n){e?s.push(`\n-ERR ${t} \n --- \n ${n.stack} \n ---`):s.push(`\n-ERR ${t}`)}}),"function"==typeof n?n({pass:i,fail:s}):(t.log(...i,...s),t.log(`\n# tests ${s.length+i.length} pass ${i.length} fail ${s.length}`),!s.length)},it:function(t){return this._tests=t,this},assert:(t,e)=>{try{if(!t)throw new Error(e||"Assertion Failed")}catch(t){throw new Error(e)}}};return t});
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "testit",
|
"name": "testit",
|
||||||
"version": "0.9.0",
|
"version": "1.0.0",
|
||||||
"description": "minimalistic testing library",
|
"description": "minimalistic testing library",
|
||||||
"main": "src/testit.js",
|
"main": "src/testit.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*! Test.it v 0.9.0 | MIT | https://github.com/n2geoff/testit */
|
/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */
|
||||||
const test = {
|
const test = {
|
||||||
"log": console.log, // eslint-disable-line
|
"log": console.log, // eslint-disable-line
|
||||||
|
"version": "v1.0.0",
|
||||||
"_tests": {},
|
"_tests": {},
|
||||||
"run": function run(errors, next) {
|
"run": function run(errors, next) {
|
||||||
// TODO: rewrite to allow a show errors flag (optional)
|
// TODO: rewrite to allow a show errors flag (optional)
|
||||||
|
|
Loading…
Reference in New Issue