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:
@@ -2,20 +2,17 @@ import ImageTile from '../../../../src/ol/ImageTile.js';
|
||||
import TileArcGISRest from '../../../../src/ol/source/TileArcGISRest.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
describe('ol.source.TileArcGISRest', function () {
|
||||
let options;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
options = {
|
||||
params: {},
|
||||
url: 'http://example.com/MapServer'
|
||||
url: 'http://example.com/MapServer',
|
||||
};
|
||||
});
|
||||
|
||||
describe('#getTile', function() {
|
||||
|
||||
it('returns a tile with the expected URL', function() {
|
||||
describe('#getTile', function () {
|
||||
it('returns a tile with the expected URL', function () {
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
|
||||
expect(tile).to.be.an(ImageTile);
|
||||
@@ -34,10 +31,9 @@ describe('ol.source.TileArcGISRest', 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 TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, 6, 1.12, getProjection('EPSG:3857'));
|
||||
const uri = new URL(tile.src_);
|
||||
@@ -45,7 +41,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
expect(queryData.get('DPI')).to.be('101');
|
||||
});
|
||||
|
||||
it('takes DPI from params if specified', function() {
|
||||
it('takes DPI from params if specified', function () {
|
||||
options.params.DPI = 96;
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, 6, 1.12, getProjection('EPSG:3857'));
|
||||
@@ -55,9 +51,11 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
delete options.params.DPI;
|
||||
});
|
||||
|
||||
it('returns a tile with the expected URL with url list', function() {
|
||||
|
||||
options.urls = ['http://test1.com/MapServer', 'http://test2.com/MapServer'];
|
||||
it('returns a tile with the expected URL with url list', function () {
|
||||
options.urls = [
|
||||
'http://test1.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
];
|
||||
const source = new TileArcGISRest(options);
|
||||
|
||||
const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
|
||||
@@ -77,10 +75,9 @@ describe('ol.source.TileArcGISRest', 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 tile with the expected URL for ImageServer', function() {
|
||||
it('returns a tile with the expected URL for ImageServer', function () {
|
||||
options.url = 'http://example.com/ImageServer';
|
||||
const source = new TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, 6, 1, getProjection('EPSG:3857'));
|
||||
@@ -102,7 +99,7 @@ describe('ol.source.TileArcGISRest', 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 TileArcGISRest(options);
|
||||
@@ -113,7 +110,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
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 TileArcGISRest(options);
|
||||
const tile = source.getTile(3, 2, 2, 1, getProjection('EPSG:4326'));
|
||||
@@ -123,9 +120,8 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#updateParams', function() {
|
||||
|
||||
it('add a new param', function() {
|
||||
describe('#updateParams', function () {
|
||||
it('add a new param', function () {
|
||||
const source = new TileArcGISRest(options);
|
||||
source.updateParams({'TEST': 'value'});
|
||||
|
||||
@@ -135,7 +131,7 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
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 TileArcGISRest(options);
|
||||
@@ -146,12 +142,10 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
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 TileArcGISRest(options);
|
||||
|
||||
@@ -160,7 +154,7 @@ describe('ol.source.TileArcGISRest', 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 TileArcGISRest(options);
|
||||
@@ -171,7 +165,7 @@ describe('ol.source.TileArcGISRest', 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 TileArcGISRest(options);
|
||||
@@ -181,52 +175,65 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
expect(setParams).to.eql({TEST: 'newValue'});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
it('verify getting array of urls', function() {
|
||||
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
|
||||
describe('#getUrls', function () {
|
||||
it('verify getting array of urls', function () {
|
||||
options.urls = [
|
||||
'http://test.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
];
|
||||
|
||||
const source = new TileArcGISRest(options);
|
||||
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test.com/MapServer', 'http://test2.com/MapServer']);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('#setUrls', function() {
|
||||
|
||||
it('verify setting urls when not set yet', function() {
|
||||
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrls(['http://test.com/MapServer', 'http://test2.com/MapServer']);
|
||||
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test.com/MapServer', 'http://test2.com/MapServer']);
|
||||
});
|
||||
|
||||
it('verify setting urls with existing list', function() {
|
||||
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
|
||||
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrls(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
|
||||
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
|
||||
expect(urls).to.eql([
|
||||
'http://test.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrl', function() {
|
||||
describe('#setUrls', function () {
|
||||
it('verify setting urls when not set yet', function () {
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrls([
|
||||
'http://test.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
]);
|
||||
|
||||
it('verify setting url with no urls', function() {
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql([
|
||||
'http://test.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
]);
|
||||
});
|
||||
|
||||
it('verify setting urls with existing list', function () {
|
||||
options.urls = [
|
||||
'http://test.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
];
|
||||
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrls([
|
||||
'http://test3.com/MapServer',
|
||||
'http://test4.com/MapServer',
|
||||
]);
|
||||
|
||||
const urls = source.getUrls();
|
||||
|
||||
expect(urls).to.eql([
|
||||
'http://test3.com/MapServer',
|
||||
'http://test4.com/MapServer',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrl', function () {
|
||||
it('verify setting url with no urls', function () {
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrl('http://test.com/MapServer');
|
||||
|
||||
@@ -235,8 +242,11 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
expect(urls).to.eql(['http://test.com/MapServer']);
|
||||
});
|
||||
|
||||
it('verify setting url with list of urls', function() {
|
||||
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
|
||||
it('verify setting url with list of urls', function () {
|
||||
options.urls = [
|
||||
'http://test.com/MapServer',
|
||||
'http://test2.com/MapServer',
|
||||
];
|
||||
|
||||
const source = new TileArcGISRest(options);
|
||||
source.setUrl('http://test3.com/MapServer');
|
||||
@@ -245,11 +255,12 @@ describe('ol.source.TileArcGISRest', function() {
|
||||
|
||||
expect(urls).to.eql(['http://test3.com/MapServer']);
|
||||
|
||||
const tileUrl = source.tileUrlFunction([0, 0, 0], 1, getProjection('EPSG:4326'));
|
||||
const tileUrl = source.tileUrlFunction(
|
||||
[0, 0, 0],
|
||||
1,
|
||||
getProjection('EPSG:4326')
|
||||
);
|
||||
expect(tileUrl.indexOf(urls[0])).to.be(0);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user