Files
openlayers/test/spec/ol/worker/webgl.test.js
Tim Schaub 054af09032 Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier.  Most formatting changes were automatically applied with this:

    npm run lint -- --fix

A few manual changes were required:

 * In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
 * In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason.  While editing this, I reworked `ExampleBuilder` to be a class.
 * In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
2020-04-06 12:54:09 -06:00

51 lines
1.4 KiB
JavaScript

import {WebGLWorkerMessageType} from '../../../../src/ol/renderer/webgl/Layer.js';
import {create} from '../../../../src/ol/worker/webgl.js';
describe('ol/worker/webgl', function () {
let worker;
beforeEach(function () {
worker = create();
});
afterEach(function () {
if (worker) {
worker.terminate();
}
worker = null;
});
describe('messaging', function () {
describe('GENERATE_BUFFERS', function () {
it('responds with buffer data', function (done) {
worker.addEventListener('error', function (error) {
expect().fail(error.message);
});
worker.addEventListener('message', function (event) {
expect(event.data.type).to.eql(
WebGLWorkerMessageType.GENERATE_BUFFERS
);
expect(event.data.renderInstructions.byteLength).to.greaterThan(0);
expect(event.data.indexBuffer.byteLength).to.greaterThan(0);
expect(event.data.vertexBuffer.byteLength).to.greaterThan(0);
expect(event.data.testInt).to.be(101);
expect(event.data.testString).to.be('abcd');
done();
});
const instructions = new Float32Array(10);
const message = {
type: WebGLWorkerMessageType.GENERATE_BUFFERS,
renderInstructions: instructions,
customAttributesCount: 0,
testInt: 101,
testString: 'abcd',
};
worker.postMessage(message);
});
});
});
});