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,34 +1,31 @@
|
||||
import EventType from '../../../../src/ol/pointer/EventType.js';
|
||||
import Map from '../../../../src/ol/Map.js';
|
||||
import MousePosition from '../../../../src/ol/control/MousePosition.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import EventType from '../../../../src/ol/pointer/EventType.js';
|
||||
|
||||
describe('ol/control/MousePosition', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('can be constructed without arguments', function() {
|
||||
describe('ol/control/MousePosition', function () {
|
||||
describe('constructor', function () {
|
||||
it('can be constructed without arguments', function () {
|
||||
const instance = new MousePosition();
|
||||
expect(instance).to.be.an(MousePosition);
|
||||
expect(instance.element.className).to.be('ol-mouse-position');
|
||||
});
|
||||
|
||||
it('creates the element with the provided class name', function() {
|
||||
it('creates the element with the provided class name', function () {
|
||||
const className = 'foobar';
|
||||
const instance = new MousePosition({
|
||||
className: className
|
||||
className: className,
|
||||
});
|
||||
expect(instance.element.className).to.be(className);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('configuration options', function() {
|
||||
describe('configuration options', function () {
|
||||
let target, map;
|
||||
const width = 360;
|
||||
const height = 180;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
target = document.createElement('div');
|
||||
const style = target.style;
|
||||
style.position = 'absolute';
|
||||
@@ -44,11 +41,11 @@ describe('ol/control/MousePosition', function() {
|
||||
view: new View({
|
||||
projection: 'EPSG:4326',
|
||||
center: [0, 0],
|
||||
resolution: 1
|
||||
})
|
||||
resolution: 1,
|
||||
}),
|
||||
});
|
||||
});
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
map.dispose();
|
||||
document.body.removeChild(target);
|
||||
});
|
||||
@@ -59,20 +56,23 @@ describe('ol/control/MousePosition', function() {
|
||||
const position = viewport.getBoundingClientRect();
|
||||
const evt = new PointerEvent(type, {
|
||||
clientX: position.left + x + width / 2,
|
||||
clientY: position.top + y + height / 2
|
||||
clientY: position.top + y + height / 2,
|
||||
});
|
||||
document.querySelector('div.ol-viewport').dispatchEvent(evt);
|
||||
}
|
||||
|
||||
describe('undefinedHTML', function() {
|
||||
it('renders undefinedHTML when mouse moves out', function() {
|
||||
describe('undefinedHTML', function () {
|
||||
it('renders undefinedHTML when mouse moves out', function () {
|
||||
const ctrl = new MousePosition({
|
||||
undefinedHTML: 'some text'
|
||||
undefinedHTML: 'some text',
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
map.renderSync();
|
||||
|
||||
const element = document.querySelector('.ol-mouse-position', map.getTarget());
|
||||
const element = document.querySelector(
|
||||
'.ol-mouse-position',
|
||||
map.getTarget()
|
||||
);
|
||||
|
||||
simulateEvent(EventType.POINTEROUT, width + 1, height + 1);
|
||||
expect(element.innerHTML).to.be('some text');
|
||||
@@ -84,12 +84,15 @@ describe('ol/control/MousePosition', function() {
|
||||
expect(element.innerHTML).to.be('some text');
|
||||
});
|
||||
|
||||
it('clears the mouse position by default when the mouse moves outside the viewport', function() {
|
||||
it('clears the mouse position by default when the mouse moves outside the viewport', function () {
|
||||
const ctrl = new MousePosition();
|
||||
ctrl.setMap(map);
|
||||
map.renderSync();
|
||||
|
||||
const element = document.querySelector('.ol-mouse-position', map.getTarget());
|
||||
const element = document.querySelector(
|
||||
'.ol-mouse-position',
|
||||
map.getTarget()
|
||||
);
|
||||
|
||||
simulateEvent(EventType.POINTEROUT, width + 1, height + 1);
|
||||
expect(element.innerHTML).to.be(' ');
|
||||
@@ -102,14 +105,17 @@ describe('ol/control/MousePosition', function() {
|
||||
expect(element.innerHTML).to.be(' ');
|
||||
});
|
||||
|
||||
it('retains the mouse position when undefinedHTML is falsey and mouse moves outside the viewport', function() {
|
||||
it('retains the mouse position when undefinedHTML is falsey and mouse moves outside the viewport', function () {
|
||||
const ctrl = new MousePosition({
|
||||
undefinedHTML: ''
|
||||
undefinedHTML: '',
|
||||
});
|
||||
ctrl.setMap(map);
|
||||
map.renderSync();
|
||||
|
||||
const element = document.querySelector('.ol-mouse-position', map.getTarget());
|
||||
const element = document.querySelector(
|
||||
'.ol-mouse-position',
|
||||
map.getTarget()
|
||||
);
|
||||
|
||||
simulateEvent(EventType.POINTEROUT, width + 1, height + 1);
|
||||
expect(element.innerHTML).to.be('');
|
||||
|
||||
Reference in New Issue
Block a user