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,54 +1,50 @@
|
||||
import BaseObject from '../../../src/ol/Object.js';
|
||||
import {listen} from '../../../src/ol/events.js';
|
||||
|
||||
|
||||
describe('ol.Object', function() {
|
||||
|
||||
describe('ol.Object', function () {
|
||||
let o;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
o = new BaseObject();
|
||||
});
|
||||
|
||||
describe('get, set and unset', function() {
|
||||
|
||||
describe('get an unset property', function() {
|
||||
describe('get, set and unset', function () {
|
||||
describe('get an unset property', function () {
|
||||
let v;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
v = o.get('k');
|
||||
});
|
||||
|
||||
it('returns undefined', function() {
|
||||
it('returns undefined', function () {
|
||||
expect(v).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('get a set property', function() {
|
||||
describe('get a set property', function () {
|
||||
let v;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
o.set('k', 1);
|
||||
v = o.get('k');
|
||||
});
|
||||
|
||||
it('returns expected value', function() {
|
||||
it('returns expected value', function () {
|
||||
expect(v).to.eql(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unset a set property', function() {
|
||||
beforeEach(function() {
|
||||
describe('unset a set property', function () {
|
||||
beforeEach(function () {
|
||||
o.set('k', 1);
|
||||
});
|
||||
|
||||
it('returns undefined', function() {
|
||||
it('returns undefined', function () {
|
||||
const v = o.unset('k');
|
||||
expect(v).to.be(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#get()', function() {
|
||||
|
||||
it('does not return values that are not explicitly set', function() {
|
||||
describe('#get()', function () {
|
||||
it('does not return values that are not explicitly set', function () {
|
||||
const o = new BaseObject();
|
||||
expect(o.get('constructor')).to.be(undefined);
|
||||
expect(o.get('hasOwnProperty')).to.be(undefined);
|
||||
@@ -58,11 +54,10 @@ describe('ol.Object', function() {
|
||||
expect(o.get('toString')).to.be(undefined);
|
||||
expect(o.get('valueOf')).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#set()', function() {
|
||||
it('can be used with arbitrary names', function() {
|
||||
describe('#set()', function () {
|
||||
it('can be used with arbitrary names', function () {
|
||||
const o = new BaseObject();
|
||||
|
||||
o.set('set', 'sat');
|
||||
@@ -77,29 +72,26 @@ describe('ol.Object', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getKeys()', function() {
|
||||
|
||||
it('returns property names set at construction', function() {
|
||||
describe('#getKeys()', function () {
|
||||
it('returns property names set at construction', function () {
|
||||
const o = new BaseObject({
|
||||
prop1: 'val1',
|
||||
prop2: 'val2',
|
||||
toString: 'string',
|
||||
get: 'foo'
|
||||
get: 'foo',
|
||||
});
|
||||
|
||||
const keys = o.getKeys();
|
||||
expect(keys.length).to.be(4);
|
||||
expect(keys.sort()).to.eql(['get', 'prop1', 'prop2', 'toString']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('setProperties', function() {
|
||||
|
||||
it('sets multiple values at once', function() {
|
||||
describe('setProperties', function () {
|
||||
it('sets multiple values at once', function () {
|
||||
o.setProperties({
|
||||
k1: 1,
|
||||
k2: 2
|
||||
k2: 2,
|
||||
});
|
||||
expect(o.get('k1')).to.eql(1);
|
||||
expect(o.get('k2')).to.eql(2);
|
||||
@@ -109,11 +101,10 @@ describe('ol.Object', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('notify', function() {
|
||||
|
||||
describe('notify', function () {
|
||||
let listener1, listener2;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
listener1 = sinon.spy();
|
||||
listen(o, 'change:k', listener1);
|
||||
|
||||
@@ -121,7 +112,7 @@ describe('ol.Object', function() {
|
||||
listen(o, 'propertychange', listener2);
|
||||
});
|
||||
|
||||
it('dispatches events', function() {
|
||||
it('dispatches events', function () {
|
||||
o.notify('k', 1);
|
||||
expect(listener1.calledOnce).to.be(true);
|
||||
const args = listener1.firstCall.args;
|
||||
@@ -131,7 +122,7 @@ describe('ol.Object', function() {
|
||||
expect(event.oldValue).to.be(1);
|
||||
});
|
||||
|
||||
it('dispatches generic change events to bound objects', function() {
|
||||
it('dispatches generic change events to bound objects', function () {
|
||||
o.notify('k', 1);
|
||||
expect(listener2.calledOnce).to.be(true);
|
||||
const args = listener2.firstCall.args;
|
||||
@@ -142,11 +133,10 @@ describe('ol.Object', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('set', function() {
|
||||
|
||||
describe('set', function () {
|
||||
let listener1, listener2;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
listener1 = sinon.spy();
|
||||
listen(o, 'change:k', listener1);
|
||||
|
||||
@@ -154,14 +144,14 @@ describe('ol.Object', function() {
|
||||
listen(o, 'propertychange', listener2);
|
||||
});
|
||||
|
||||
it('dispatches events to object', function() {
|
||||
it('dispatches events to object', function () {
|
||||
o.set('k', 1);
|
||||
expect(listener1.called).to.be(true);
|
||||
|
||||
expect(o.getKeys()).to.eql(['k']);
|
||||
});
|
||||
|
||||
it('dispatches generic change events to object', function() {
|
||||
it('dispatches generic change events to object', function () {
|
||||
o.set('k', 1);
|
||||
expect(listener2.calledOnce).to.be(true);
|
||||
const args = listener2.firstCall.args;
|
||||
@@ -170,24 +160,23 @@ describe('ol.Object', function() {
|
||||
expect(event.key).to.be('k');
|
||||
});
|
||||
|
||||
it('dispatches events only if the value is different', function() {
|
||||
it('dispatches events only if the value is different', function () {
|
||||
o.set('k', 1);
|
||||
o.set('k', 1);
|
||||
expect(listener1.calledOnce).to.be(true);
|
||||
expect(listener2.calledOnce).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('setter', function() {
|
||||
beforeEach(function() {
|
||||
o.setX = function(x) {
|
||||
describe('setter', function () {
|
||||
beforeEach(function () {
|
||||
o.setX = function (x) {
|
||||
this.set('x', x);
|
||||
};
|
||||
sinon.spy(o, 'setX');
|
||||
});
|
||||
|
||||
it('does not call the setter', function() {
|
||||
it('does not call the setter', function () {
|
||||
o.set('x', 1);
|
||||
expect(o.get('x')).to.eql(1);
|
||||
expect(o.setX.called).to.be(false);
|
||||
@@ -196,22 +185,22 @@ describe('ol.Object', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getter', function() {
|
||||
beforeEach(function() {
|
||||
o.getX = function() {
|
||||
describe('getter', function () {
|
||||
beforeEach(function () {
|
||||
o.getX = function () {
|
||||
return 1;
|
||||
};
|
||||
sinon.spy(o, 'getX');
|
||||
});
|
||||
|
||||
it('does not call the getter', function() {
|
||||
it('does not call the getter', function () {
|
||||
expect(o.get('x')).to.be(undefined);
|
||||
expect(o.getX.called).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('create with options', function() {
|
||||
it('sets the property', function() {
|
||||
describe('create with options', function () {
|
||||
it('sets the property', function () {
|
||||
const o = new BaseObject({k: 1});
|
||||
expect(o.get('k')).to.eql(1);
|
||||
|
||||
@@ -219,17 +208,17 @@ describe('ol.Object', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('case sensitivity', function() {
|
||||
describe('case sensitivity', function () {
|
||||
let listener1, listener2;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
listener1 = sinon.spy();
|
||||
listen(o, 'change:k', listener1);
|
||||
listener2 = sinon.spy();
|
||||
listen(o, 'change:K', listener2);
|
||||
});
|
||||
|
||||
it('dispatches the expected event', function() {
|
||||
it('dispatches the expected event', function () {
|
||||
o.set('K', 1);
|
||||
expect(listener1.called).to.be(false);
|
||||
expect(listener2.called).to.be(true);
|
||||
@@ -237,5 +226,4 @@ describe('ol.Object', function() {
|
||||
expect(o.getKeys()).to.eql(['K']);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user