named functions on core methods

This commit is contained in:
Geoff Doty 2018-11-09 11:18:46 -05:00
parent 18e11a4842
commit 6c437a619e
4 changed files with 13 additions and 13 deletions

10
dist/testit.js vendored
View File

@ -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": {

4
dist/testit.min.js vendored
View File

@ -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});
/*! 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});

View File

@ -1,6 +1,6 @@
{
"name": "testit",
"version": "0.7.0",
"version": "0.7.1",
"description": "a minimalistic testing library",
"main": "src/testit.js",
"directories": {

View File

@ -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": {