mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-07 09:25:33 +00:00
Test for mocking importScripts; spruce up tests.
This commit is contained in:
parent
84257770da
commit
324764c1bd
1 changed files with 22 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue