Add worker loader to the tests

This commit is contained in:
Tim Schaub
2019-05-15 16:49:54 -06:00
parent 05f13bb363
commit b7b37f9548
2 changed files with 40 additions and 0 deletions

View File

@@ -86,6 +86,14 @@ module.exports = function(karma) {
},
include: path.resolve('src/ol/'),
exclude: path.resolve('node_modules/')
}, {
test: /\.js$/,
use: {
loader: path.join(__dirname, '../examples/webpack/worker-loader.js')
},
include: [
path.join(__dirname, '../src/ol/worker')
]
}
]
}

View File

@@ -0,0 +1,32 @@
import {create} from '../../../../src/ol/worker/version.js';
import {VERSION} from '../../../../src/ol/util.js';
describe('ol/worker/version', function() {
let worker;
beforeEach(function() {
worker = create();
});
afterEach(function() {
if (worker) {
worker.terminate();
}
worker = null;
});
describe('messaging', function() {
it('responds with the version', function(done) {
worker.addEventListener('error', done);
worker.addEventListener('message', function(event) {
expect(event.data).to.equal('version: ' + VERSION);
done();
});
worker.postMessage('test message');
});
});
});