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,163 +1,153 @@
|
||||
import Point from '../../../../src/ol/geom/Point.js';
|
||||
import {get as getProjection, getTransformFromProjections} from '../../../../src/ol/proj.js';
|
||||
import {
|
||||
get as getProjection,
|
||||
getTransformFromProjections,
|
||||
} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.geom.Point', function() {
|
||||
|
||||
it('cannot be constructed with a null geometry', function() {
|
||||
expect(function() {
|
||||
describe('ol.geom.Point', function () {
|
||||
it('cannot be constructed with a null geometry', function () {
|
||||
expect(function () {
|
||||
return new Point(null);
|
||||
}).to.throwException();
|
||||
});
|
||||
|
||||
describe('construct with 2D coordinates', function() {
|
||||
|
||||
describe('construct with 2D coordinates', function () {
|
||||
let point;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
point = new Point([1, 2]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
it('has the expected layout', function () {
|
||||
expect(point.getLayout()).to.be('XY');
|
||||
});
|
||||
|
||||
it('has the expected coordinates', function() {
|
||||
it('has the expected coordinates', function () {
|
||||
expect(point.getCoordinates()).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('has the expected extent', function() {
|
||||
it('has the expected extent', function () {
|
||||
expect(point.getExtent()).to.eql([1, 2, 1, 2]);
|
||||
});
|
||||
|
||||
it('has the expected flat coordinates', function() {
|
||||
it('has the expected flat coordinates', function () {
|
||||
expect(point.getFlatCoordinates()).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('has stride the expected stride', function() {
|
||||
it('has stride the expected stride', function () {
|
||||
expect(point.getStride()).to.be(2);
|
||||
});
|
||||
|
||||
it('does not intersect non matching extent', function() {
|
||||
it('does not intersect non matching extent', function () {
|
||||
expect(point.intersectsExtent([0, 0, 10, 0.5])).to.be(false);
|
||||
});
|
||||
|
||||
it('does intersect it\'s extent', function() {
|
||||
it("does intersect it's extent", function () {
|
||||
expect(point.intersectsExtent(point.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('construct with 3D coordinates and layout XYM', function() {
|
||||
|
||||
describe('construct with 3D coordinates and layout XYM', function () {
|
||||
let point;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
point = new Point([1, 2, 3], 'XYM');
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
it('has the expected layout', function () {
|
||||
expect(point.getLayout()).to.be('XYM');
|
||||
});
|
||||
|
||||
it('has the expected coordinates', function() {
|
||||
it('has the expected coordinates', function () {
|
||||
expect(point.getCoordinates()).to.eql([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('has the expected extent', function() {
|
||||
it('has the expected extent', function () {
|
||||
expect(point.getExtent()).to.eql([1, 2, 1, 2]);
|
||||
});
|
||||
|
||||
it('has the expected flat coordinates', function() {
|
||||
it('has the expected flat coordinates', function () {
|
||||
expect(point.getFlatCoordinates()).to.eql([1, 2, 3]);
|
||||
});
|
||||
|
||||
it('has the expected stride', function() {
|
||||
it('has the expected stride', function () {
|
||||
expect(point.getStride()).to.be(3);
|
||||
});
|
||||
|
||||
it('does not intersect non matching extent', function() {
|
||||
it('does not intersect non matching extent', function () {
|
||||
expect(point.intersectsExtent([0, 0, 10, 0.5])).to.be(false);
|
||||
});
|
||||
|
||||
it('does intersect it\'s extent', function() {
|
||||
it("does intersect it's extent", function () {
|
||||
expect(point.intersectsExtent(point.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('construct with 4D coordinates', function() {
|
||||
|
||||
describe('construct with 4D coordinates', function () {
|
||||
let point;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
point = new Point([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
it('has the expected layout', function () {
|
||||
expect(point.getLayout()).to.be('XYZM');
|
||||
});
|
||||
|
||||
it('has the expected coordinates', function() {
|
||||
it('has the expected coordinates', function () {
|
||||
expect(point.getCoordinates()).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('has the expected extent', function() {
|
||||
it('has the expected extent', function () {
|
||||
expect(point.getExtent()).to.eql([1, 2, 1, 2]);
|
||||
});
|
||||
|
||||
it('has the expected flat coordinates', function() {
|
||||
it('has the expected flat coordinates', function () {
|
||||
expect(point.getFlatCoordinates()).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
it('has the expected stride', function() {
|
||||
it('has the expected stride', function () {
|
||||
expect(point.getStride()).to.be(4);
|
||||
});
|
||||
|
||||
it('does not intersect non matching extent', function() {
|
||||
it('does not intersect non matching extent', function () {
|
||||
expect(point.intersectsExtent([0, 0, 10, 0.5])).to.be(false);
|
||||
});
|
||||
|
||||
it('does intersect it\'s extent', function() {
|
||||
it("does intersect it's extent", function () {
|
||||
expect(point.intersectsExtent(point.getExtent())).to.be(true);
|
||||
});
|
||||
|
||||
describe('#getClosestPoint', function() {
|
||||
|
||||
it('preseves extra dimensions', function() {
|
||||
describe('#getClosestPoint', function () {
|
||||
it('preseves extra dimensions', function () {
|
||||
const closestPoint = point.getClosestPoint([0, 0]);
|
||||
expect(closestPoint).to.eql([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a point', function() {
|
||||
describe('#scale()', function () {
|
||||
it('scales a point', function () {
|
||||
const geom = new Point([1, 2]);
|
||||
geom.scale(10e6);
|
||||
const coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
it('accepts sx and sy', function () {
|
||||
const geom = new Point([1, 2]);
|
||||
geom.scale(1e6, -42);
|
||||
const coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([1, 2]);
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
it('accepts an anchor', function () {
|
||||
const geom = new Point([1, 2]);
|
||||
geom.scale(10, 15, [0, 0]);
|
||||
const coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([10, 30]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#simplifyTransformed()', function() {
|
||||
|
||||
it('returns the same result if called twice with the same arguments', function() {
|
||||
describe('#simplifyTransformed()', function () {
|
||||
it('returns the same result if called twice with the same arguments', function () {
|
||||
const geom = new Point([1, 2]);
|
||||
const source = getProjection('EPSG:4326');
|
||||
const dest = getProjection('EPSG:3857');
|
||||
@@ -168,7 +158,7 @@ describe('ol.geom.Point', function() {
|
||||
expect(second).to.be(first);
|
||||
});
|
||||
|
||||
it('returns a different result if called with a different tolerance', function() {
|
||||
it('returns a different result if called with a different tolerance', function () {
|
||||
const geom = new Point([1, 2]);
|
||||
const source = getProjection('EPSG:4326');
|
||||
const dest = getProjection('EPSG:3857');
|
||||
@@ -179,7 +169,7 @@ describe('ol.geom.Point', function() {
|
||||
expect(second).not.to.be(first);
|
||||
});
|
||||
|
||||
it('returns a different result if called after geometry modification', function() {
|
||||
it('returns a different result if called after geometry modification', function () {
|
||||
const geom = new Point([1, 2]);
|
||||
const source = getProjection('EPSG:4326');
|
||||
const dest = getProjection('EPSG:3857');
|
||||
@@ -191,18 +181,16 @@ describe('ol.geom.Point', function() {
|
||||
const second = geom.simplifyTransformed(squaredTolerance * 2, transform);
|
||||
expect(second).not.to.be(first);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#applyTransform()', function() {
|
||||
|
||||
describe('#applyTransform()', function () {
|
||||
let point, transform;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
point = new Point([1, 2]);
|
||||
transform = sinon.spy();
|
||||
});
|
||||
|
||||
it('calls a transform function', function() {
|
||||
it('calls a transform function', function () {
|
||||
point.applyTransform(transform);
|
||||
expect(transform.calledOnce).to.be(true);
|
||||
const args = transform.firstCall.args;
|
||||
@@ -213,8 +201,8 @@ describe('ol.geom.Point', function() {
|
||||
expect(args[2]).to.be(2); // dimension
|
||||
});
|
||||
|
||||
it('allows for modification of coordinates', function() {
|
||||
const mod = function(input, output, dimension) {
|
||||
it('allows for modification of coordinates', function () {
|
||||
const mod = function (input, output, dimension) {
|
||||
const copy = input.slice();
|
||||
output[1] = copy[0];
|
||||
output[0] = copy[1];
|
||||
@@ -223,18 +211,15 @@ describe('ol.geom.Point', function() {
|
||||
expect(point.getCoordinates()).to.eql([2, 1]);
|
||||
});
|
||||
|
||||
it('returns undefined', function() {
|
||||
it('returns undefined', function () {
|
||||
const got = point.applyTransform(transform);
|
||||
expect(got).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#transform()', function() {
|
||||
|
||||
it('transforms a geometry given CRS identifiers', function() {
|
||||
const point = new Point([-111, 45]).transform(
|
||||
'EPSG:4326', 'EPSG:3857');
|
||||
describe('#transform()', function () {
|
||||
it('transforms a geometry given CRS identifiers', function () {
|
||||
const point = new Point([-111, 45]).transform('EPSG:4326', 'EPSG:3857');
|
||||
|
||||
expect(point).to.be.a(Point);
|
||||
|
||||
@@ -244,7 +229,7 @@ describe('ol.geom.Point', function() {
|
||||
expect(coords[1]).to.roughlyEqual(5621521.48, 1e-2);
|
||||
});
|
||||
|
||||
it('modifies the original', function() {
|
||||
it('modifies the original', function () {
|
||||
const point = new Point([-111, 45]);
|
||||
point.transform('EPSG:4326', 'EPSG:3857');
|
||||
const coords = point.getCoordinates();
|
||||
@@ -252,25 +237,21 @@ describe('ol.geom.Point', function() {
|
||||
expect(coords[0]).to.roughlyEqual(-12356463.47, 1e-2);
|
||||
expect(coords[1]).to.roughlyEqual(5621521.48, 1e-2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#containsXY()', function() {
|
||||
|
||||
it('does contain XY', function() {
|
||||
describe('#containsXY()', function () {
|
||||
it('does contain XY', function () {
|
||||
const point = new Point([1, 2]);
|
||||
|
||||
expect(point.containsXY(1, 2)).to.be(true);
|
||||
});
|
||||
|
||||
it('does not contain XY', function() {
|
||||
it('does not contain XY', function () {
|
||||
const point = new Point([1, 2]);
|
||||
|
||||
expect(point.containsXY(1, 3)).to.be(false);
|
||||
expect(point.containsXY(2, 2)).to.be(false);
|
||||
expect(point.containsXY(2, 3)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user