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.
58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
import CanvasVectorImageLayerRenderer from '../../../../../src/ol/renderer/canvas/VectorImageLayer.js';
|
|
import VectorImageLayer from '../../../../../src/ol/layer/VectorImage.js';
|
|
import VectorSource from '../../../../../src/ol/source/Vector.js';
|
|
import {create} from '../../../../../src/ol/transform.js';
|
|
import {get as getProjection} from '../../../../../src/ol/proj.js';
|
|
import {scaleFromCenter} from '../../../../../src/ol/extent.js';
|
|
|
|
describe('ol/renderer/canvas/VectorImageLayer', function () {
|
|
describe('#dispose()', function () {
|
|
it('cleans up CanvasVectorRenderer', function () {
|
|
const layer = new VectorImageLayer({
|
|
source: new VectorSource(),
|
|
});
|
|
const renderer = new CanvasVectorImageLayerRenderer(layer);
|
|
const spy = sinon.spy(renderer.vectorRenderer_, 'dispose');
|
|
renderer.dispose();
|
|
expect(spy.called).to.be(true);
|
|
});
|
|
});
|
|
|
|
describe('#prepareFrame', function () {
|
|
it('sets correct extent with imageRatio = 2', function () {
|
|
const layer = new VectorImageLayer({
|
|
imageRatio: 2,
|
|
source: new VectorSource(),
|
|
});
|
|
const renderer = new CanvasVectorImageLayerRenderer(layer);
|
|
const projection = getProjection('EPSG:3857');
|
|
const projExtent = projection.getExtent();
|
|
const extent = [
|
|
projExtent[0] - 10000,
|
|
-10000,
|
|
projExtent[0] + 10000,
|
|
10000,
|
|
];
|
|
const frameState = {
|
|
layerStatesArray: [layer.getLayerState()],
|
|
layerIndex: 0,
|
|
extent: extent,
|
|
viewHints: [],
|
|
pixelToCoordinateTransform: create(),
|
|
viewState: {
|
|
center: [0, 0],
|
|
projection: projection,
|
|
resolution: 1,
|
|
rotation: 0,
|
|
},
|
|
};
|
|
renderer.prepareFrame(frameState);
|
|
const expected = renderer.image_.getExtent();
|
|
|
|
scaleFromCenter(extent, 2);
|
|
|
|
expect(expected).to.eql(extent);
|
|
});
|
|
});
|
|
});
|