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.
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
import DragZoom from '../../../../src/ol/interaction/DragZoom.js';
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
import RenderBox from '../../../../src/ol/render/Box.js';
|
||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import {getCenter} from '../../../../src/ol/extent.js';
|
||||
import {fromExtent as polygonFromExtent} from '../../../../src/ol/geom/Polygon.js';
|
||||
import DragZoom from '../../../../src/ol/interaction/DragZoom.js';
|
||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||
import RenderBox from '../../../../src/ol/render/Box.js';
|
||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||
|
||||
|
||||
describe('ol.interaction.DragZoom', function() {
|
||||
|
||||
describe('ol.interaction.DragZoom', function () {
|
||||
let target, map, source;
|
||||
|
||||
const width = 360;
|
||||
const height = 180;
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
target = document.createElement('div');
|
||||
const style = target.style;
|
||||
style.position = 'absolute';
|
||||
@@ -32,41 +30,38 @@ describe('ol.interaction.DragZoom', function() {
|
||||
view: new View({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
})
|
||||
resolution: 1,
|
||||
}),
|
||||
});
|
||||
map.once('postrender', function() {
|
||||
map.once('postrender', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
map.dispose();
|
||||
document.body.removeChild(target);
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
describe('constructor', function () {
|
||||
it('can be constructed without arguments', function () {
|
||||
const instance = new DragZoom();
|
||||
expect(instance).to.be.an(DragZoom);
|
||||
});
|
||||
it('sets "ol-dragzoom" as box className', function() {
|
||||
it('sets "ol-dragzoom" as box className', function () {
|
||||
const instance = new DragZoom();
|
||||
expect(instance.box_.element_.className).to.be('ol-box ol-dragzoom');
|
||||
});
|
||||
it('sets a custom box className', function() {
|
||||
it('sets a custom box className', function () {
|
||||
const instance = new DragZoom({className: 'test-dragzoom'});
|
||||
expect(instance.box_.element_.className).to.be('ol-box test-dragzoom');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#onBoxEnd()', function() {
|
||||
|
||||
it('centers the view on the box geometry', function(done) {
|
||||
describe('#onBoxEnd()', function () {
|
||||
it('centers the view on the box geometry', function (done) {
|
||||
const interaction = new DragZoom({
|
||||
duration: 10
|
||||
duration: 10,
|
||||
});
|
||||
map.addInteraction(interaction);
|
||||
|
||||
@@ -76,19 +71,18 @@ describe('ol.interaction.DragZoom', function() {
|
||||
interaction.box_ = box;
|
||||
|
||||
interaction.onBoxEnd_();
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
const view = map.getView();
|
||||
const center = view.getCenterInternal();
|
||||
expect(center).to.eql(getCenter(extent));
|
||||
done();
|
||||
}, 50);
|
||||
|
||||
});
|
||||
|
||||
it('sets new resolution while zooming out', function(done) {
|
||||
it('sets new resolution while zooming out', function (done) {
|
||||
const interaction = new DragZoom({
|
||||
duration: 10,
|
||||
out: true
|
||||
out: true,
|
||||
});
|
||||
map.addInteraction(interaction);
|
||||
|
||||
@@ -98,19 +92,15 @@ describe('ol.interaction.DragZoom', function() {
|
||||
interaction.box_ = box;
|
||||
|
||||
map.getView().setResolution(0.25);
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
interaction.onBoxEnd_();
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
const view = map.getView();
|
||||
const resolution = view.getResolution();
|
||||
expect(resolution).to.eql(view.getConstrainedResolution(0.5));
|
||||
done();
|
||||
}, 50);
|
||||
}, 50);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user