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,26 +1,28 @@
|
||||
import ImageArcGISRest from '../../../../src/ol/source/ImageArcGISRest.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.source.ImageArcGISRest', function() {
|
||||
|
||||
describe('ol.source.ImageArcGISRest', function () {
|
||||
let pixelRatio, options, projection, proj3857, resolution;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
pixelRatio = 1;
|
||||
projection = getProjection('EPSG:4326');
|
||||
proj3857 = getProjection('EPSG:3857');
|
||||
resolution = 0.1;
|
||||
options = {
|
||||
params: {},
|
||||
url: 'http://example.com/MapServer'
|
||||
url: 'http://example.com/MapServer',
|
||||
};
|
||||
});
|
||||
|
||||
describe('#getImage', function() {
|
||||
|
||||
it('returns a image with the expected URL', function() {
|
||||
describe('#getImage', function () {
|
||||
it('returns a image with the expected URL', function () {
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const image = source.getImage(
|
||||
[3, 2, -7, 1],
|
||||
resolution,
|
||||
pixelRatio,
|
||||
proj3857
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
@@ -31,21 +33,30 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
expect(queryData.get('IMAGESR')).to.be('3857');
|
||||
expect(queryData.get('BBOXSR')).to.be('3857');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('true');
|
||||
|
||||
});
|
||||
|
||||
it('returns a non floating point DPI value', function() {
|
||||
it('returns a non floating point DPI value', function () {
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -7, 1.12], resolution, 1.01, proj3857);
|
||||
const image = source.getImage(
|
||||
[3, 2, -7, 1.12],
|
||||
resolution,
|
||||
1.01,
|
||||
proj3857
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('DPI')).to.be('91');
|
||||
});
|
||||
|
||||
it('returns a image with the expected URL for ImageServer', function() {
|
||||
it('returns a image with the expected URL for ImageServer', function () {
|
||||
options.url = 'http://example.com/ImageServer';
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const image = source.getImage(
|
||||
[3, 2, -7, 1],
|
||||
resolution,
|
||||
pixelRatio,
|
||||
proj3857
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
@@ -58,56 +69,73 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
expect(queryData.get('TRANSPARENT')).to.be('true');
|
||||
});
|
||||
|
||||
it('allows various parameters to be overridden', function() {
|
||||
it('allows various parameters to be overridden', function () {
|
||||
options.params.FORMAT = 'png';
|
||||
options.params.TRANSPARENT = false;
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, projection);
|
||||
const image = source.getImage(
|
||||
[3, 2, -3, 1],
|
||||
resolution,
|
||||
pixelRatio,
|
||||
projection
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('FORMAT')).to.be('png');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('false');
|
||||
});
|
||||
|
||||
it('allows adding rest option', function() {
|
||||
it('allows adding rest option', function () {
|
||||
options.params.LAYERS = 'show:1,3,4';
|
||||
const source = new ImageArcGISRest(options);
|
||||
const image = source.getImage([3, 2, -3, 1], resolution, pixelRatio, proj3857);
|
||||
const image = source.getImage(
|
||||
[3, 2, -3, 1],
|
||||
resolution,
|
||||
pixelRatio,
|
||||
proj3857
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#updateParams', function() {
|
||||
|
||||
it('add a new param', function() {
|
||||
describe('#updateParams', function () {
|
||||
it('add a new param', function () {
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.updateParams({'TEST': 'value'});
|
||||
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const image = source.getImage(
|
||||
[3, 2, -7, 1],
|
||||
resolution,
|
||||
pixelRatio,
|
||||
proj3857
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('value');
|
||||
});
|
||||
|
||||
it('updates an existing param', function() {
|
||||
it('updates an existing param', function () {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.updateParams({'TEST': 'newValue'});
|
||||
|
||||
const image = source.getImage([3, 2, -7, 1], resolution, pixelRatio, proj3857);
|
||||
const image = source.getImage(
|
||||
[3, 2, -7, 1],
|
||||
resolution,
|
||||
pixelRatio,
|
||||
proj3857
|
||||
);
|
||||
const uri = new URL(image.src_);
|
||||
const queryData = uri.searchParams;
|
||||
expect(queryData.get('TEST')).to.be('newValue');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getParams', function() {
|
||||
|
||||
it('verify getting a param', function() {
|
||||
describe('#getParams', function () {
|
||||
it('verify getting a param', function () {
|
||||
options.params.TEST = 'value';
|
||||
const source = new ImageArcGISRest(options);
|
||||
|
||||
@@ -116,7 +144,7 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
expect(setParams).to.eql({TEST: 'value'});
|
||||
});
|
||||
|
||||
it('verify on adding a param', function() {
|
||||
it('verify on adding a param', function () {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
const source = new ImageArcGISRest(options);
|
||||
@@ -127,7 +155,7 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
expect(setParams).to.eql({TEST: 'value', TEST2: 'newValue'});
|
||||
});
|
||||
|
||||
it('verify on update a param', function() {
|
||||
it('verify on update a param', function () {
|
||||
options.params.TEST = 'value';
|
||||
|
||||
const source = new ImageArcGISRest(options);
|
||||
@@ -137,12 +165,10 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
|
||||
expect(setParams).to.eql({TEST: 'newValue'});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getUrl', function() {
|
||||
|
||||
it('verify getting url', function() {
|
||||
describe('#getUrl', function () {
|
||||
it('verify getting url', function () {
|
||||
options.url = 'http://test.com/MapServer';
|
||||
|
||||
const source = new ImageArcGISRest(options);
|
||||
@@ -151,14 +177,10 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
|
||||
expect(url).to.eql('http://test.com/MapServer');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('#setUrl', function() {
|
||||
|
||||
it('verify setting url when not set yet', function() {
|
||||
|
||||
describe('#setUrl', function () {
|
||||
it('verify setting url when not set yet', function () {
|
||||
const source = new ImageArcGISRest(options);
|
||||
source.setUrl('http://test.com/MapServer');
|
||||
|
||||
@@ -167,7 +189,7 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
expect(url).to.eql('http://test.com/MapServer');
|
||||
});
|
||||
|
||||
it('verify setting url with existing url', function() {
|
||||
it('verify setting url with existing url', function () {
|
||||
options.url = 'http://test.com/MapServer';
|
||||
|
||||
const source = new ImageArcGISRest(options);
|
||||
@@ -178,6 +200,4 @@ describe('ol.source.ImageArcGISRest', function() {
|
||||
expect(url).to.eql('http://test2.com/MapServer');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user