mocha-patch.min.js 2.47 KB
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(this,function(){"use strict";!function(n){function e(n,e,t){for(var r=function(r){var o=n[r];"function"==typeof o&&(n[r]=0===o.length?e(o):t(o),n[r].toString=function(){return o.toString()})},o=0;o<n.length;o++)r(o);return n}function t(n){var t=function(n){return function(){return s.run(n,this,arguments)}};return e(n,t)}function r(n){var t=function(n){return function(e){return a.run(n,this,[e])}},r=function(n){return function(){return a.run(n,this)}};return e(n,r,t)}function o(n){var t=function(n){return function(e){return p.run(n,this,[e])}},r=function(n){return function(){return p.run(n,this)}};return e(n,r,t)}var i=n.Mocha;if("undefined"==typeof i)throw new Error("Missing Mocha.js");if("undefined"==typeof Zone)throw new Error("Missing Zone.js");var u=Zone.ProxyZoneSpec,c=Zone.SyncTestZoneSpec;if(!u)throw new Error("Missing ProxyZoneSpec");if(i.__zone_patch__)throw new Error('"Mocha" has already been patched with "Zone".');i.__zone_patch__=!0;var f=Zone.current,s=f.fork(new c("Mocha.describe")),a=null,p=f.fork(new u),h={after:i.after,afterEach:i.afterEach,before:i.before,beforeEach:i.beforeEach,describe:i.describe,it:i.it};n.describe=n.suite=i.describe=function(){return h.describe.apply(this,t(arguments))},n.xdescribe=n.suite.skip=i.describe.skip=function(){return h.describe.skip.apply(this,t(arguments))},n.describe.only=n.suite.only=i.describe.only=function(){return h.describe.only.apply(this,t(arguments))},n.it=n.specify=n.test=i.it=function(){return h.it.apply(this,r(arguments))},n.xit=n.xspecify=i.it.skip=function(){return h.it.skip.apply(this,r(arguments))},n.it.only=n.test.only=i.it.only=function(){return h.it.only.apply(this,r(arguments))},n.after=n.suiteTeardown=i.after=function(){return h.after.apply(this,o(arguments))},n.afterEach=n.teardown=i.afterEach=function(){return h.afterEach.apply(this,r(arguments))},n.before=n.suiteSetup=i.before=function(){return h.before.apply(this,o(arguments))},n.beforeEach=n.setup=i.beforeEach=function(){return h.beforeEach.apply(this,r(arguments))},function(n,e){i.Runner.prototype.runTest=function(e){var t=this;Zone.current.scheduleMicroTask("mocha.forceTask",function(){n.call(t,e)})},i.Runner.prototype.run=function(n){return this.on("test",function(n){if(Zone.current!==f)throw new Error("Unexpected zone: "+Zone.current.name);a=f.fork(new u)}),e.call(this,n)}}(i.Runner.prototype.runTest,i.Runner.prototype.run)}(window)});