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,46 +1,45 @@
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import Control from '../../../../src/ol/control/Control.js';
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
import OverviewMap from '../../../../src/ol/control/OverviewMap.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
|
||||
describe('ol.control.OverviewMap', function() {
|
||||
describe('ol.control.OverviewMap', function () {
|
||||
let map, target;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
target = document.createElement('div');
|
||||
document.body.appendChild(target);
|
||||
map = new Map({
|
||||
target: target
|
||||
target: target,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
map.dispose();
|
||||
document.body.removeChild(target);
|
||||
map = null;
|
||||
target = null;
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates an overview map with the default options', function() {
|
||||
describe('constructor', function () {
|
||||
it('creates an overview map with the default options', function () {
|
||||
const control = new OverviewMap();
|
||||
expect(control).to.be.a(OverviewMap);
|
||||
expect(control).to.be.a(Control);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setMap()', function() {
|
||||
|
||||
it('keeps ovmap view rotation in sync with map view rotation', function() {
|
||||
describe('setMap()', function () {
|
||||
it('keeps ovmap view rotation in sync with map view rotation', function () {
|
||||
const view = new View({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
rotation: Math.PI / 2
|
||||
rotation: Math.PI / 2,
|
||||
});
|
||||
map.setView(view);
|
||||
|
||||
const control = new OverviewMap({
|
||||
rotateWithView: true
|
||||
rotateWithView: true,
|
||||
});
|
||||
map.addControl(control);
|
||||
const ovView = control.ovmap_.getView();
|
||||
@@ -50,9 +49,9 @@ describe('ol.control.OverviewMap', function() {
|
||||
expect(ovView.getRotation()).to.be(Math.PI / 4);
|
||||
});
|
||||
|
||||
it('maintains rotation in sync if view added later', function() {
|
||||
it('maintains rotation in sync if view added later', function () {
|
||||
const control = new OverviewMap({
|
||||
rotateWithView: true
|
||||
rotateWithView: true,
|
||||
});
|
||||
map.addControl(control);
|
||||
const ovInitialView = control.ovmap_.getView();
|
||||
@@ -61,7 +60,7 @@ describe('ol.control.OverviewMap', function() {
|
||||
const view = new View({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
rotation: Math.PI / 2
|
||||
rotation: Math.PI / 2,
|
||||
});
|
||||
map.setView(view);
|
||||
const ovView = control.ovmap_.getView();
|
||||
@@ -71,15 +70,15 @@ describe('ol.control.OverviewMap', function() {
|
||||
expect(ovView.getRotation()).to.be(Math.PI / 4);
|
||||
});
|
||||
|
||||
it('stops listening to old maps', function() {
|
||||
it('stops listening to old maps', function () {
|
||||
const control = new OverviewMap({
|
||||
rotateWithView: true
|
||||
rotateWithView: true,
|
||||
});
|
||||
|
||||
const view = new View({
|
||||
center: [0, 0],
|
||||
zoom: 0,
|
||||
rotation: 0
|
||||
rotation: 0,
|
||||
});
|
||||
map.setView(view);
|
||||
map.addControl(control);
|
||||
@@ -94,39 +93,51 @@ describe('ol.control.OverviewMap', function() {
|
||||
expect(ovView.getRotation()).to.be(Math.PI / 8);
|
||||
});
|
||||
|
||||
it('reflects projection change of main map', function() {
|
||||
it('reflects projection change of main map', function () {
|
||||
const control = new OverviewMap({
|
||||
rotateWithView: true
|
||||
rotateWithView: true,
|
||||
});
|
||||
|
||||
map.addControl(control);
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be('EPSG:3857');
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be(
|
||||
'EPSG:3857'
|
||||
);
|
||||
|
||||
map.setView(new View({
|
||||
projection: 'EPSG:4326'
|
||||
}));
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be('EPSG:4326');
|
||||
map.setView(
|
||||
new View({
|
||||
projection: 'EPSG:4326',
|
||||
})
|
||||
);
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be(
|
||||
'EPSG:4326'
|
||||
);
|
||||
});
|
||||
|
||||
it('retains explicitly set view', function() {
|
||||
it('retains explicitly set view', function () {
|
||||
const overviewMapView = new View();
|
||||
const control = new OverviewMap({
|
||||
rotateWithView: true,
|
||||
view: overviewMapView
|
||||
view: overviewMapView,
|
||||
});
|
||||
|
||||
map.addControl(control);
|
||||
expect(control.ovmap_.getView()).to.be(overviewMapView);
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be('EPSG:3857');
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be(
|
||||
'EPSG:3857'
|
||||
);
|
||||
|
||||
map.setView(new View({
|
||||
projection: 'EPSG:4326'
|
||||
}));
|
||||
map.setView(
|
||||
new View({
|
||||
projection: 'EPSG:4326',
|
||||
})
|
||||
);
|
||||
expect(control.ovmap_.getView()).to.be(overviewMapView);
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be('EPSG:3857');
|
||||
expect(control.ovmap_.getView().getProjection().getCode()).to.be(
|
||||
'EPSG:3857'
|
||||
);
|
||||
});
|
||||
|
||||
it('set target to null', function() {
|
||||
it('set target to null', function () {
|
||||
const control = new OverviewMap();
|
||||
|
||||
map.addControl(control);
|
||||
@@ -137,7 +148,5 @@ describe('ol.control.OverviewMap', function() {
|
||||
|
||||
expect(control.ovmap_.getTarget()).to.be(null);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user