-
Notifications
You must be signed in to change notification settings - Fork 1
/
mochai.min.js
2 lines (2 loc) · 2.49 KB
/
mochai.min.js
1
2
!function(a){"use strict";for(var b=function(){},c=function(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return void 0!==b&&null!==b&&c===a},d=!("function"!=typeof define||!define.amd),e={VERSION:"0.2.4",DEBUG:a.DEBUG||!1,suites:{},runner:null,mochaPhantomJS:a.mochaPhantomJS||void 0,libs:{},setuped:!1,setup:function(b,e){var f=this;b=b||{ui:"bdd"},f.isMochaPhantomJS=function(){return!!a.mochaPhantomJS},f.addSuite=function(a,b){var e=this,f=function(a,b){for(var d in a){var f=a[d];if(!c("Object",f))throw new Error("Suite is not an Object.");for(var g in f)e.suites[g]=f[g],e.DEBUG&&console.log("add test:",g)}return b&&b(null,e.suites),this};c("Array",a)||(a=[a]);var g=[];for(var h in a){var i=a[h];c("String",i)?g.push(i):c("Object",i)&&f([i])}return d&&0<g.length?(require(g,function(){var a=Array.prototype.slice.call(arguments);f(a,function(){b&&b()})}),this):void(b&&b())},f.run=function(a,b){var d,e=this,f=a,g=[];if(!this.setuped)throw new Error('"mochai.setup()" is not running.');if(this.libs.mocha.suite.suites=[],this.suites[a])if(this.libs.mocha.checkLeaks(),this.isMochaPhantomJS()){for(var h in e.suites)d=e.suites[h],g.push(d());this.runner=this.mochaPhantomJS.run()}else{c("Array",a)||(f=[a]);for(var i in f)e.suites[f[i]]();this.runner=this.libs.mocha.run(b)}},f.ConsoleReporter=function(a){var b=0,c=0,d=[],e=[];a.on("pass",function(a){d.push({data:a}),b++}),a.on("fail",function(a,b){d.push({data:a,error:b}),c++}),a.on("end",function(){e.push("- Mochai results\n");for(var a in d){var f=d[a],g=f.data,h=f.error;"failed"===g.state&&e.push(" [ NG ] "+g.fullTitle()+" error: "+h.message),"passed"===g.state&&e.push(" [ OK ] "+g.fullTitle())}var i=b+"/"+(b+c);e.push(""),c>0?(e.push("Total: "+i),console.error(e.join("\n"))):(e.push("Total: "+i),console.warn(e.join("\n")))})};var g=function(b){return f.libs.chai=a.chai,f.libs.mocha=a.mocha,b&&b.apply(f,arguments),this},h=function(b){return require(["require","chai","mocha"],function(c,d,e){f.libs.chai=d,f.libs.mocha=e,f.libs.mocha||(f.libs.mocha=a.mocha),b&&b.apply(f,arguments)}),this},i=g;d&&(i=h),i(function(){this.isMochaPhantomJS()||b.reporter||(b.reporter=this.ConsoleReporter),this.libs.mocha.setup(b),a.assert=this.libs.chai.assert,a.expect=this.libs.chai.expect,f.setuped=!0,e&&e(this)})}},f=["initialize","isMochaPhantomJS","run"],g=0;g<f.length;g++)e[f[g]]=b;for(var h=["initialize","isMochaPhantomJS","run"],g=0;g<h.length;g++)e[h[g]]=function(a,b){b&&b()};d?define([],function(){return e}):a.mochai=e}(window);
//# sourceMappingURL=mochai.min.map