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,12 +1,10 @@
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
import UrlTile from '../../../../src/ol/source/UrlTile.js';
|
||||
import {createXYZ} from '../../../../src/ol/tilegrid.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
|
||||
|
||||
describe('ol.source.UrlTile', function() {
|
||||
|
||||
describe('#setUrl()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
describe('ol.source.UrlTile', function () {
|
||||
describe('#setUrl()', function () {
|
||||
it('sets the URL for the source', function () {
|
||||
const source = new UrlTile({});
|
||||
|
||||
const url = 'https://example.com/';
|
||||
@@ -15,7 +13,7 @@ describe('ol.source.UrlTile', function() {
|
||||
expect(source.getUrls()).to.eql([url]);
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
it('updates the key for the source', function () {
|
||||
const source = new UrlTile({});
|
||||
|
||||
const url = 'https://example.com/';
|
||||
@@ -25,27 +23,27 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setUrls()', function() {
|
||||
it('sets the URL for the source', function() {
|
||||
describe('#setUrls()', function () {
|
||||
it('sets the URL for the source', function () {
|
||||
const source = new UrlTile({});
|
||||
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
'https://c.example.com/',
|
||||
];
|
||||
source.setUrls(urls);
|
||||
|
||||
expect(source.getUrls()).to.eql(urls);
|
||||
});
|
||||
|
||||
it('updates the key for the source', function() {
|
||||
it('updates the key for the source', function () {
|
||||
const source = new UrlTile({});
|
||||
|
||||
const urls = [
|
||||
'https://a.example.com/',
|
||||
'https://b.example.com/',
|
||||
'https://c.example.com/'
|
||||
'https://c.example.com/',
|
||||
];
|
||||
source.setUrls(urls);
|
||||
|
||||
@@ -53,10 +51,10 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('url option', function() {
|
||||
it('expands url template', function() {
|
||||
describe('url option', function () {
|
||||
it('expands url template', function () {
|
||||
const tileSource = new UrlTile({
|
||||
url: '{1-3}'
|
||||
url: '{1-3}',
|
||||
});
|
||||
|
||||
const urls = tileSource.getUrls();
|
||||
@@ -64,150 +62,149 @@ describe('ol.source.UrlTile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('tileUrlFunction', function() {
|
||||
|
||||
describe('tileUrlFunction', function () {
|
||||
let tileSource, tileGrid;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
tileSource = new UrlTile({
|
||||
projection: 'EPSG:3857',
|
||||
tileGrid: createXYZ({maxZoom: 6}),
|
||||
url: '{z}/{x}/{y}',
|
||||
wrapX: true
|
||||
wrapX: true,
|
||||
});
|
||||
tileGrid = tileSource.getTileGrid();
|
||||
});
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
|
||||
it('returns the expected URL', function () {
|
||||
const coordinate = [829330.2064098881, 5933916.615134273];
|
||||
let tileUrl;
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 0)
|
||||
);
|
||||
expect(tileUrl).to.eql('0/0/0');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 1)
|
||||
);
|
||||
expect(tileUrl).to.eql('1/1/0');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 2)
|
||||
);
|
||||
expect(tileUrl).to.eql('2/2/1');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 3)
|
||||
);
|
||||
expect(tileUrl).to.eql('3/4/2');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 4)
|
||||
);
|
||||
expect(tileUrl).to.eql('4/8/5');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 5)
|
||||
);
|
||||
expect(tileUrl).to.eql('5/16/11');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
|
||||
tileGrid.getTileCoordForCoordAndZ(coordinate, 6)
|
||||
);
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
});
|
||||
|
||||
describe('wrap x', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
describe('wrap x', function () {
|
||||
it('returns the expected URL', function () {
|
||||
const projection = tileSource.getProjection();
|
||||
let tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction([6, -31, 22], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, -31, 22], projection)
|
||||
);
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection)
|
||||
);
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 97, 22], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 97, 22], projection)
|
||||
);
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('crop y', function() {
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
describe('crop y', function () {
|
||||
it('returns the expected URL', function () {
|
||||
const projection = tileSource.getProjection();
|
||||
let tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, -1], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, -1], projection)
|
||||
);
|
||||
expect(tileUrl).to.be(undefined);
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 22], projection)
|
||||
);
|
||||
expect(tileUrl).to.eql('6/33/22');
|
||||
|
||||
tileUrl = tileSource.tileUrlFunction(
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 64], projection));
|
||||
tileSource.getTileCoordForTileUrlFunction([6, 33, 64], projection)
|
||||
);
|
||||
expect(tileUrl).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getUrls', function() {
|
||||
|
||||
describe('#getUrls', function () {
|
||||
let sourceOptions;
|
||||
let source;
|
||||
const url = 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png';
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
sourceOptions = {
|
||||
tileGrid: createXYZ({
|
||||
extent: getProjection('EPSG:4326').getExtent()
|
||||
})
|
||||
extent: getProjection('EPSG:4326').getExtent(),
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('using a "url" option', function() {
|
||||
beforeEach(function() {
|
||||
describe('using a "url" option', function () {
|
||||
beforeEach(function () {
|
||||
sourceOptions.url = url;
|
||||
source = new UrlTile(sourceOptions);
|
||||
});
|
||||
|
||||
it('returns the XYZ URL', function() {
|
||||
it('returns the XYZ URL', function () {
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql([url]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('using a "urls" option', function() {
|
||||
beforeEach(function() {
|
||||
describe('using a "urls" option', function () {
|
||||
beforeEach(function () {
|
||||
sourceOptions.urls = ['some_xyz_url1', 'some_xyz_url2'];
|
||||
source = new UrlTile(sourceOptions);
|
||||
});
|
||||
|
||||
it('returns the XYZ URLs', function() {
|
||||
it('returns the XYZ URLs', function () {
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be.eql(['some_xyz_url1', 'some_xyz_url2']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('using a "tileUrlFunction"', function() {
|
||||
beforeEach(function() {
|
||||
sourceOptions.tileUrlFunction = function() {
|
||||
describe('using a "tileUrlFunction"', function () {
|
||||
beforeEach(function () {
|
||||
sourceOptions.tileUrlFunction = function () {
|
||||
return 'some_xyz_url';
|
||||
};
|
||||
source = new UrlTile(sourceOptions);
|
||||
});
|
||||
|
||||
it('returns null', function() {
|
||||
it('returns null', function () {
|
||||
const urls = source.getUrls();
|
||||
expect(urls).to.be(null);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user