From 6c437a619ee05456a9a99b4f0d3ae5cef83de04c Mon Sep 17 00:00:00 2001 From: Geoff Doty Date: Fri, 9 Nov 2018 11:18:46 -0500 Subject: [PATCH] named functions on core methods --- dist/testit.js | 10 +++++----- dist/testit.min.js | 4 ++-- package.json | 2 +- src/testit.js | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dist/testit.js b/dist/testit.js index c9634d7..0cf1734 100644 --- a/dist/testit.js +++ b/dist/testit.js @@ -1,4 +1,4 @@ -/*! Test.it v 0.7.0 | MIT | https://github.com/n2geoff/testit */ +/*! Test.it v 0.7.1 | MIT | https://github.com/n2geoff/testit */ (function (root, factory) { "use strict"; if (typeof module === "object" && module.exports) { @@ -11,13 +11,13 @@ const test = { "_tests": {}, - "run": function (next) { + "run": function run(next) { let tests = this._tests; let failed = []; let passed = []; - Object.keys(tests).forEach(function (name) { + Object.keys(tests).forEach((name) => { let test = tests[name]; try { @@ -41,11 +41,11 @@ return failed.length ? false : true; } }, - "it": function (tests) { + "it": function it(tests) { this._tests = tests; return this; }, - "expects": (val) => { + "expects": function expects(val) { return { "to": { "be": { diff --git a/dist/testit.min.js b/dist/testit.min.js index e297a89..9a829c4 100644 --- a/dist/testit.min.js +++ b/dist/testit.min.js @@ -1,2 +1,2 @@ -/*! Test.it v 0.7.0 | 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}); \ No newline at end of file +/*! Test.it v 0.7.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(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:function(e){return{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}); \ No newline at end of file diff --git a/package.json b/package.json index 35f76c5..2c70847 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "testit", - "version": "0.7.0", + "version": "0.7.1", "description": "a minimalistic testing library", "main": "src/testit.js", "directories": { diff --git a/src/testit.js b/src/testit.js index 5657dab..10041fa 100644 --- a/src/testit.js +++ b/src/testit.js @@ -1,4 +1,4 @@ -/*! Test.it v 0.7.0 | MIT | https://github.com/n2geoff/testit */ +/*! Test.it v 0.7.1 | MIT | https://github.com/n2geoff/testit */ (function (root, factory) { "use strict"; // support browser & commonjs @@ -12,7 +12,7 @@ const test = { "_tests": {}, - "run": function (next) { + "run": function run(next) { let tests = this._tests; // capture results @@ -20,7 +20,7 @@ let passed = []; // loop through tests - Object.keys(tests).forEach(function (name) { + Object.keys(tests).forEach((name) => { let test = tests[name]; // execute @@ -46,11 +46,11 @@ return failed.length ? false : true; } }, - "it": function (tests) { + "it": function it(tests) { this._tests = tests; return this; }, - "expects": (val) => { + "expects": function expects(val) { return { "to": { "be": {