Add worker loader to the tests
This commit is contained in:
@@ -86,6 +86,14 @@ module.exports = function(karma) {
|
|||||||
},
|
},
|
||||||
include: path.resolve('src/ol/'),
|
include: path.resolve('src/ol/'),
|
||||||
exclude: path.resolve('node_modules/')
|
exclude: path.resolve('node_modules/')
|
||||||
|
}, {
|
||||||
|
test: /\.js$/,
|
||||||
|
use: {
|
||||||
|
loader: path.join(__dirname, '../examples/webpack/worker-loader.js')
|
||||||
|
},
|
||||||
|
include: [
|
||||||
|
path.join(__dirname, '../src/ol/worker')
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user