Taking the example code from http://ift.tt/1BVug3J , the following is run by a web worker
// in worker.js
onmessage = function(e) {
console.log('Message received from main script');
var workerResult = 'Result: ' + (e.data[0] * e.data[1]);
console.log('Posting message back to main script');
postMessage(workerResult);
}
run by code in an Angular service/factory
var myWorker = new Worker("worker.js");
I would like to be able to unit test the code in worker.js, ideally running it as part of an Angular service/factory (in a separate app running in the web worker?), so I can use the DI system to inject mocks of dependencies, and have the unit test code looking much like the tests for any other service. How can I do this?
Aucun commentaire:
Enregistrer un commentaire