blob: cba6f57d0a98a665fff074c68912aa13394a1e71 [file] [log] [blame]
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(0,function(){"use strict";!function(n){var e=n.Mocha;if(void 0===e)throw new Error("Missing Mocha.js");if("undefined"==typeof Zone)throw new Error("Missing Zone.js");var t=Zone.ProxyZoneSpec,r=Zone.SyncTestZoneSpec;if(!t)throw new Error("Missing ProxyZoneSpec");if(e.__zone_patch__)throw new Error('"Mocha" has already been patched with "Zone".');e.__zone_patch__=!0;var i,o,u=Zone.current,f=u.fork(new r("Mocha.describe")),c=null,s=u.fork(new t),a={after:e.after,afterEach:e.afterEach,before:e.before,beforeEach:e.beforeEach,describe:e.describe,it:e.it};function p(n,e,t){for(var r=function(r){var i=n[r];"function"==typeof i&&(n[r]=0===i.length?e(i):t(i),n[r].toString=function(){return i.toString()})},i=0;i<n.length;i++)r(i);return n}function h(n){return p(n,function(n){return function(){return f.run(n,this,arguments)}})}function y(n){return p(n,function(n){return function(){return c.run(n,this)}},function(n){return function(e){return c.run(n,this,[e])}})}function d(n){return p(n,function(n){return function(){return s.run(n,this)}},function(n){return function(e){return s.run(n,this,[e])}})}n.describe=n.suite=e.describe=function(){return a.describe.apply(this,h(arguments))},n.xdescribe=n.suite.skip=e.describe.skip=function(){return a.describe.skip.apply(this,h(arguments))},n.describe.only=n.suite.only=e.describe.only=function(){return a.describe.only.apply(this,h(arguments))},n.it=n.specify=n.test=e.it=function(){return a.it.apply(this,y(arguments))},n.xit=n.xspecify=e.it.skip=function(){return a.it.skip.apply(this,y(arguments))},n.it.only=n.test.only=e.it.only=function(){return a.it.only.apply(this,y(arguments))},n.after=n.suiteTeardown=e.after=function(){return a.after.apply(this,d(arguments))},n.afterEach=n.teardown=e.afterEach=function(){return a.afterEach.apply(this,y(arguments))},n.before=n.suiteSetup=e.before=function(){return a.before.apply(this,d(arguments))},n.beforeEach=n.setup=e.beforeEach=function(){return a.beforeEach.apply(this,y(arguments))},i=e.Runner.prototype.runTest,o=e.Runner.prototype.run,e.Runner.prototype.runTest=function(n){var e=this;Zone.current.scheduleMicroTask("mocha.forceTask",function(){i.call(e,n)})},e.Runner.prototype.run=function(n){return this.on("test",function(n){c=u.fork(new t)}),this.on("fail",function(n,e){var t=c&&c.get("ProxyZoneSpec");if(t&&e)try{e.message+=t.getAndClearPendingTasksInfo()}catch(n){}}),o.call(this,n)}}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global)});