mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-10 01:27:43 +00:00
32 lines
996 B
JavaScript
32 lines
996 B
JavaScript
var assert = chai.assert;
|
|
describe('LMLayerWorker', function () {
|
|
describe('LMLayerWorkerCode', function() {
|
|
it('should exist!', function() {
|
|
assert.isFunction(LMLayerWorkerCode,
|
|
'Could not find LMLayerWorkerCode! Does embedded_worker.js exist?'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('Usage within a Web Worker', function () {
|
|
it('should install itself in the worker context', function (done) {
|
|
let wrapper = LMLayerWorkerCode.toString();
|
|
let match = wrapper.match(/function[^{]+{((?:.|\n)+)}[^}]*$/);
|
|
assert.isNotNull(match);
|
|
let code = match[1];
|
|
assert.isString(code);
|
|
|
|
let blob = new Blob([code], { type: 'text/javascript' });
|
|
let uri = URL.createObjectURL(blob);
|
|
|
|
let worker = new Worker(uri);
|
|
worker.onmessage = function thisShouldBeCalled(message) {
|
|
done();
|
|
};
|
|
worker.postMessage({
|
|
message: 'initialize',
|
|
model: "return {model: {}, configuration: {}}"
|
|
});
|
|
});
|
|
});
|
|
})
|