Test for mocking importScripts; spruce up tests.

This commit is contained in:
Eddie Antonio Santos 2018-11-19 10:56:01 -07:00
parent 84257770da
commit 324764c1bd
No known key found for this signature in database
GPG key ID: DD411EA4D9509D87

View file

@ -17,6 +17,22 @@ describe('LMLayerWorker', function() {
assert(fakePostMessage.calledOnce);
});
it('should allow for the mocking of importScripts()', function () {
var fakeImportScripts;
var worker = new LMLayerWorker({
postMessage: sinon.fake(), // required, but ignored in this test case
importScripts: fakeImportScripts = sinon.fake()
});
// Sending it the initialize it should notify us that it's initialized!
worker.onMessage(createMessageEventWithData({
message: 'initialize',
model: 'en-x-dummy'
}));
assert.isTrue(fakeImportScripts.calledOnce);
});
// TODO: remove from here; convert into integration test
it('should work with zero arguments within a Web Worker', function() {
var fakePostMessage;
var WorkerInSandbox = defineLMLayerWorkerWithinSandbox({
@ -99,6 +115,12 @@ describe('LMLayerWorker', function() {
});
});
describe('Message: predict', function () {
it.skip('should predict from a local model', function () {
// will need import scripts figured out
});
});
/**
* Creates a MessageEvent (for inter-worker communication), with the given data payload.
* @param {*} data