mirror of https://github.com/n2geoff/testit.git
fixed linting errors
This commit is contained in:
parent
5a84cc9a65
commit
faf34affa8
|
@ -1,25 +1,26 @@
|
|||
/* Test.it v 0.5.1 | MIT | https://github.com/n2geoff/testit */
|
||||
(function(root, factory) {
|
||||
/* Test.it v 0.5.2 | MIT | https://github.com/n2geoff/testit */
|
||||
;(function (root, factory) {
|
||||
"use strict";
|
||||
// support browser & commonjs
|
||||
if(typeof module === "object" && module.exports) {
|
||||
if (typeof module === "object" && module.exports) {
|
||||
module.exports = factory(root.test);
|
||||
} else {
|
||||
root.test = factory(root.test);
|
||||
}
|
||||
}(this, function() {
|
||||
'use strict';
|
||||
}(this, function () {
|
||||
"use strict";
|
||||
|
||||
const test = {
|
||||
_tests: {},
|
||||
run: function(next) {
|
||||
|
||||
"_tests": {},
|
||||
"run": function (next) {
|
||||
|
||||
let tests = this._tests;
|
||||
// capture results
|
||||
let failed = [];
|
||||
let passed = [];
|
||||
|
||||
// loop through tests
|
||||
Object.keys(tests).forEach(function(name) {
|
||||
Object.keys(tests).forEach(function (name) {
|
||||
let test = tests[name];
|
||||
|
||||
// execute
|
||||
|
@ -38,7 +39,7 @@
|
|||
});
|
||||
|
||||
// summary
|
||||
if(typeof next === 'function') {
|
||||
if(typeof next === "function") {
|
||||
return next({
|
||||
pass: passed,
|
||||
fail: failed
|
||||
|
@ -50,16 +51,16 @@
|
|||
return failed.length ? false : true;
|
||||
}
|
||||
},
|
||||
it: function(tests) {
|
||||
"it": function (tests) {
|
||||
this._tests = tests;
|
||||
return this;
|
||||
},
|
||||
assert: function (e, a) { if (e != a) throw Error(`expected ${e} == ${a}`); },
|
||||
equals: function (e, a) { if (e !== a) throw Error(`expected ${e} === ${a}`); },
|
||||
exists: function (v) { if (!v) throw Error(`exists value ${v}`); },
|
||||
pass: function () { return true; },
|
||||
fail: function (m) { throw Error(m); }
|
||||
}
|
||||
"assert": function (e, a) { if (e != a) throw Error(`expected ${e} == ${a}`); },
|
||||
"equals": function (e, a) { if (e !== a) throw Error(`expected ${e} === ${a}`); },
|
||||
"exists": function (v) { if (!v) throw Error(`exists value ${v}`); },
|
||||
"pass": function () { return true; },
|
||||
"fail": function (m) { throw Error(m); }
|
||||
};
|
||||
|
||||
return test;
|
||||
}));
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
/* Test.it v 0.5.1 | MIT | https://github.com/n2geoff/testit */
|
||||
;(function(root,factory){if(typeof module==="object"&&module.exports){module.exports=factory(root.test)}else{root.test=factory(root.test)}})(this,function(){"use strict";const test={_tests:{},run:function(next){let tests=this._tests;let failed=[];let passed=[];Object.keys(tests).forEach(function(name){let test=tests[name];try{test();passed.push(`\n+ ${name}`)}catch(err){failed.push(`\n- ${name}`);console.error(err)}});if(typeof next==="function"){return next({pass:passed,fail:failed})}else{console.log(...passed,...failed);console.log(`\n# tests ${failed.length+passed.length} pass ${passed.length} fail ${failed.length}`);return failed.length?false:true}},it:function(tests){this._tests=tests;return this},assert:function(e,a){if(e!=a)throw Error(`expected ${e} == ${a}`)},equals:function(e,a){if(e!==a)throw Error(`expected ${e} === ${a}`)},exists:function(v){if(!v)throw Error(`exists value ${v}`)},pass:function(){return true},fail:function(m){throw Error(m)}};return test});
|
||||
/* Test.it v 0.5.2 | MIT | https://github.com/n2geoff/testit */
|
||||
;(function(root,factory){"use strict";if(typeof module==="object"&&module.exports){module.exports=factory(root.test)}else{root.test=factory(root.test)}})(this,function(){"use strict";const test={_tests:{},run:function(next){let tests=this._tests;let failed=[];let passed=[];Object.keys(tests).forEach(function(name){let test=tests[name];try{test();passed.push(`\n+ ${name}`)}catch(err){failed.push(`\n- ${name}`);console.error(err)}});if(typeof next==="function"){return next({pass:passed,fail:failed})}else{console.log(...passed,...failed);console.log(`\n# tests ${failed.length+passed.length} pass ${passed.length} fail ${failed.length}`);return failed.length?false:true}},it:function(tests){this._tests=tests;return this},assert:function(e,a){if(e!=a)throw Error(`expected ${e} == ${a}`)},equals:function(e,a){if(e!==a)throw Error(`expected ${e} === ${a}`)},exists:function(v){if(!v)throw Error(`exists value ${v}`)},pass:function(){return true},fail:function(m){throw Error(m)}};return test});
|
||||
|
|
Loading…
Reference in New Issue