Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions
+57 -57
View File
@@ -5,7 +5,7 @@ import {get as getProjection} from '../../../../src/ol/proj.js';
describe('ol.source.TileArcGISRest', function() {
var options;
let options;
beforeEach(function() {
options = {
params: {},
@@ -16,15 +16,15 @@ describe('ol.source.TileArcGISRest', function() {
describe('#getTile', function() {
it('returns a tile with the expected URL', function() {
var source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_);
const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com');
expect(uri.pathname).to.be('/MapServer/export');
var queryData = uri.searchParams;
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
const queryData = uri.searchParams;
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
@@ -38,19 +38,19 @@ describe('ol.source.TileArcGISRest', function() {
});
it('returns a non floating point DPI value', function() {
var source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
const uri = new URL(tile.src_);
const queryData = uri.searchParams;
expect(queryData.get('DPI')).to.be('101');
});
it('takes DPI from params if specified', function() {
options.params.DPI = 96;
var source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1.12, getProjection('EPSG:3857'));
const uri = new URL(tile.src_);
const queryData = uri.searchParams;
expect(queryData.get('DPI')).to.be('108');
delete options.params.DPI;
});
@@ -58,16 +58,16 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL with url list', function() {
options.urls = ['http://test1.com/MapServer', 'http://test2.com/MapServer'];
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_);
const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.match(/test[12]\.com/);
expect(uri.pathname).to.be('/MapServer/export');
var queryData = uri.searchParams;
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
const queryData = uri.searchParams;
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
@@ -82,15 +82,15 @@ describe('ol.source.TileArcGISRest', function() {
it('returns a tile with the expected URL for ImageServer', function() {
options.url = 'http://example.com/ImageServer';
var source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
expect(tile).to.be.an(ImageTile);
var uri = new URL(tile.src_);
const uri = new URL(tile.src_);
expect(uri.protocol).to.be('http:');
expect(uri.hostname).to.be('example.com');
expect(uri.pathname).to.be('/ImageServer/exportImage');
var queryData = uri.searchParams;
var bbox = queryData.get('BBOX').split(',').map(parseFloat);
const queryData = uri.searchParams;
const bbox = queryData.get('BBOX').split(',').map(parseFloat);
expect(bbox[0]).roughlyEqual(-10018754.171394622, 1e-9);
expect(bbox[1]).roughlyEqual(-15028131.257091936, 1e-9);
expect(bbox[2]).roughlyEqual(-5009377.085697311, 1e-9);
@@ -105,20 +105,20 @@ describe('ol.source.TileArcGISRest', function() {
it('allows various parameters to be overridden', function() {
options.params.FORMAT = 'png';
options.params.TRANSPARENT = false;
var source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.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() {
options.params.LAYERS = 'show:1,3,4';
var source = new TileArcGISRest(options);
var tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
const source = new TileArcGISRest(options);
const tile = source.getTile(3, 2, -3, 1, getProjection('EPSG:4326'));
const uri = new URL(tile.src_);
const queryData = uri.searchParams;
expect(queryData.get('LAYERS')).to.be('show:1,3,4');
});
});
@@ -126,24 +126,24 @@ describe('ol.source.TileArcGISRest', function() {
describe('#updateParams', function() {
it('add a new param', function() {
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.updateParams({'TEST': 'value'});
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
const uri = new URL(tile.src_);
const queryData = uri.searchParams;
expect(queryData.get('TEST')).to.be('value');
});
it('updates an existing param', function() {
options.params.TEST = 'value';
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.updateParams({'TEST': 'newValue'});
var tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
var uri = new URL(tile.src_);
var queryData = uri.searchParams;
const tile = source.getTile(3, 2, -7, 1, getProjection('EPSG:3857'));
const uri = new URL(tile.src_);
const queryData = uri.searchParams;
expect(queryData.get('TEST')).to.be('newValue');
});
@@ -153,9 +153,9 @@ describe('ol.source.TileArcGISRest', function() {
it('verify getting a param', function() {
options.params.TEST = 'value';
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
var setParams = source.getParams();
const setParams = source.getParams();
expect(setParams).to.eql({TEST: 'value'});
});
@@ -163,10 +163,10 @@ describe('ol.source.TileArcGISRest', function() {
it('verify on adding a param', function() {
options.params.TEST = 'value';
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.updateParams({'TEST2': 'newValue'});
var setParams = source.getParams();
const setParams = source.getParams();
expect(setParams).to.eql({TEST: 'value', TEST2: 'newValue'});
});
@@ -174,10 +174,10 @@ describe('ol.source.TileArcGISRest', function() {
it('verify on update a param', function() {
options.params.TEST = 'value';
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.updateParams({'TEST': 'newValue'});
var setParams = source.getParams();
const setParams = source.getParams();
expect(setParams).to.eql({TEST: 'newValue'});
});
@@ -189,9 +189,9 @@ describe('ol.source.TileArcGISRest', function() {
it('verify getting array of urls', function() {
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
var urls = source.getUrls();
const urls = source.getUrls();
expect(urls).to.eql(['http://test.com/MapServer', 'http://test2.com/MapServer']);
});
@@ -203,10 +203,10 @@ describe('ol.source.TileArcGISRest', function() {
it('verify setting urls when not set yet', function() {
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.setUrls(['http://test.com/MapServer', 'http://test2.com/MapServer']);
var urls = source.getUrls();
const urls = source.getUrls();
expect(urls).to.eql(['http://test.com/MapServer', 'http://test2.com/MapServer']);
});
@@ -214,10 +214,10 @@ describe('ol.source.TileArcGISRest', function() {
it('verify setting urls with existing list', function() {
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.setUrls(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
var urls = source.getUrls();
const urls = source.getUrls();
expect(urls).to.eql(['http://test3.com/MapServer', 'http://test4.com/MapServer']);
});
@@ -227,10 +227,10 @@ describe('ol.source.TileArcGISRest', function() {
it('verify setting url with no urls', function() {
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.setUrl('http://test.com/MapServer');
var urls = source.getUrls();
const urls = source.getUrls();
expect(urls).to.eql(['http://test.com/MapServer']);
});
@@ -238,14 +238,14 @@ describe('ol.source.TileArcGISRest', function() {
it('verify setting url with list of urls', function() {
options.urls = ['http://test.com/MapServer', 'http://test2.com/MapServer'];
var source = new TileArcGISRest(options);
const source = new TileArcGISRest(options);
source.setUrl('http://test3.com/MapServer');
var urls = source.getUrls();
const urls = source.getUrls();
expect(urls).to.eql(['http://test3.com/MapServer']);
var 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);
});