-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.min.js
21 lines (20 loc) · 2.03 KB
/
worker.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function fileContents(path){return files[path]}function importingFile(path){return function(){eval(fileContents(path))}}function setupEnvironment(mocha,chai){chai.assert
mocha.setup("bdd"),chai.use(function(chai,utils){var Assertion=chai.Assertion
Assertion.overwriteMethod("throw",function(_super){return function(_,message){try{var flag=utils.flag
_super.apply(this,arguments)}catch(e){if(void 0===message)throw e
this.assert(flag(this,"negate"),message,message,e.expected,e.actual)}}}),Assertion.overwriteMethod("equal",function(_super){return function(_,message){try{var flag=utils.flag
_super.apply(this,[arguments[0]])}catch(e){if(void 0===message)throw e
this.assert(flag(this,"negate"),message,message,e.expected,e.actual)}}}),Assertion.overwriteMethod("match",function(_super){return function(_,message){try{var flag=utils.flag
_super.apply(this,[arguments[0]])}catch(e){if(void 0===message)throw e
this.assert(flag(this,"negate"),message,message,e.expected,e.actual)}}}),Assertion.addMethod("type",function(type,message){try{var flag=utils.flag,obj=flag(this,"object")
new Assertion(obj).to.be.a(type)}catch(e){if(void 0===message)throw e
this.assert(flag(this,"negate"),message,message,e.expected,e.actual)}})})}function runTests(_testSource,mocha,chai){const expect=chai.expect
eval(_testSource),mocha.run().on("pass",function(test){var pass={result:test.state,title:test.title}
passed.push(pass)}).on("fail",function(test,error){var fail={result:test.state,timedOut:test.timedOut,title:test.title,error:error.message}
failed.push(fail)}).on("end",function(){var result={status:"complete",passed:passed,failed:failed}
postMessage(result)})}var files,passed=[],failed=[]
onmessage=function(event){var message=event.data
const url=message.url
importScripts(url+"/js/polyfill.min.js"),importScripts(url+"/js/mocha.min.js"),importScripts(url+"/js/chai.min.js"),importScripts(url+"/js/sinon.min.js"),setupEnvironment(mocha,chai),mocha.reporter(function(){})
var testSource=message.testSource
files=message.files,runTests(testSource,mocha,chai)},postMessage({status:"ready"})