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:
@@ -6,12 +6,12 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
|
||||
|
||||
describe('ol.source.Zoomify', function() {
|
||||
var w = 1024;
|
||||
var h = 512;
|
||||
var size = [w, h];
|
||||
var zoomifyUrl = 'spec/ol/source/images/zoomify/{TileGroup}/{z}-{x}-{y}.jpg';
|
||||
var iipUrl = 'spec/ol/source/images/zoomify?JTL={z},{tileIndex}';
|
||||
var proj = new Projection({
|
||||
const w = 1024;
|
||||
const h = 512;
|
||||
const size = [w, h];
|
||||
const zoomifyUrl = 'spec/ol/source/images/zoomify/{TileGroup}/{z}-{x}-{y}.jpg';
|
||||
const iipUrl = 'spec/ol/source/images/zoomify?JTL={z},{tileIndex}';
|
||||
const proj = new Projection({
|
||||
code: 'ZOOMIFY',
|
||||
units: 'pixels',
|
||||
extent: [0, 0, w, h]
|
||||
@@ -46,7 +46,7 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('constructor', function() {
|
||||
|
||||
it('requires config "size"', function() {
|
||||
var source;
|
||||
let source;
|
||||
|
||||
// undefined config object
|
||||
expect(function() {
|
||||
@@ -122,9 +122,9 @@ describe('ol.source.Zoomify', function() {
|
||||
});
|
||||
|
||||
it('creates a tileGrid for both protocols', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid).to.be.a(TileGrid);
|
||||
}
|
||||
});
|
||||
@@ -134,61 +134,61 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('generated tileGrid', function() {
|
||||
|
||||
it('has expected extent', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
var expectedExtent = [0, -h, w, 0];
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
const expectedExtent = [0, -h, w, 0];
|
||||
expect(tileGrid.getExtent()).to.eql(expectedExtent);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected origin', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
var expectedOrigin = [0, 0];
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
const expectedOrigin = [0, 0];
|
||||
expect(tileGrid.getOrigin()).to.eql(expectedOrigin);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected resolutions', function() {
|
||||
var sources = [getZoomifySource(), getIIPSource()];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
var expectedResolutions = [4, 2, 1];
|
||||
const sources = [getZoomifySource(), getIIPSource()];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
const expectedResolutions = [4, 2, 1];
|
||||
expect(tileGrid.getResolutions()).to.eql(expectedResolutions);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected tileSize', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWith1024pxTiles()];
|
||||
var expectedTileSizes = [DEFAULT_TILE_SIZE, 1024];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
const sources = [getZoomifySource(), getZoomifySourceWith1024pxTiles()];
|
||||
const expectedTileSizes = [DEFAULT_TILE_SIZE, 1024];
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getTileSize()).to.eql(expectedTileSizes[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected extent', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
var expectedExtents = [
|
||||
const sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
const expectedExtents = [
|
||||
[0, -size[1], size[0], 0],
|
||||
[0, 0, size[0], size[1]]
|
||||
];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getExtent()).to.eql(expectedExtents[i]);
|
||||
}
|
||||
});
|
||||
|
||||
it('has expected origin', function() {
|
||||
var sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
var expectedOrigins = [
|
||||
const sources = [getZoomifySource(), getZoomifySourceWithExtentInFirstQuadrant()];
|
||||
const expectedOrigins = [
|
||||
[0, 0],
|
||||
[0, size[1]]
|
||||
];
|
||||
for (var i = 0; i < sources.length; i++) {
|
||||
var tileGrid = sources[i].getTileGrid();
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
const tileGrid = sources[i].getTileGrid();
|
||||
expect(tileGrid.getOrigin()).to.eql(expectedOrigins[i]);
|
||||
}
|
||||
});
|
||||
@@ -199,27 +199,27 @@ describe('ol.source.Zoomify', function() {
|
||||
|
||||
it('influences resolutions', function() {
|
||||
// not configured at all
|
||||
var source = new Zoomify({
|
||||
const source = new Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: [513, 256]
|
||||
});
|
||||
var tileGrid = source.getTileGrid();
|
||||
const tileGrid = source.getTileGrid();
|
||||
|
||||
// explicitly set as 'default'
|
||||
var sourceDefault = new Zoomify({
|
||||
const sourceDefault = new Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: [513, 256],
|
||||
tierSizeCalculation: 'default'
|
||||
});
|
||||
var tileGridDefault = sourceDefault.getTileGrid();
|
||||
const tileGridDefault = sourceDefault.getTileGrid();
|
||||
|
||||
// explicitly set to 'truncated'
|
||||
var sourceTruncated = new Zoomify({
|
||||
const sourceTruncated = new Zoomify({
|
||||
url: zoomifyUrl,
|
||||
size: [513, 256],
|
||||
tierSizeCalculation: 'truncated'
|
||||
});
|
||||
var tileGridTruncated = sourceTruncated.getTileGrid();
|
||||
const tileGridTruncated = sourceTruncated.getTileGrid();
|
||||
|
||||
expect(tileGrid.getResolutions()).to.eql([4, 2, 1]);
|
||||
expect(tileGridDefault.getResolutions()).to.eql([4, 2, 1]);
|
||||
@@ -231,8 +231,8 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('generated tileUrlFunction for zoomify protocol', function() {
|
||||
|
||||
it('creates an expected tileUrlFunction with zoomify template', function() {
|
||||
var source = getZoomifySource();
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const source = getZoomifySource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// zoomlevel 0
|
||||
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg');
|
||||
// zoomlevel 1
|
||||
@@ -242,8 +242,8 @@ describe('ol.source.Zoomify', function() {
|
||||
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg');
|
||||
});
|
||||
it('creates an expected tileUrlFunction with IIP template', function() {
|
||||
var source = getIIPSource();
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const source = getIIPSource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// zoomlevel 0
|
||||
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify?JTL=0,0');
|
||||
// zoomlevel 1
|
||||
@@ -254,11 +254,11 @@ describe('ol.source.Zoomify', function() {
|
||||
});
|
||||
|
||||
it('creates an expected tileUrlFunction without template', function() {
|
||||
var source = new Zoomify({
|
||||
const source = new Zoomify({
|
||||
url: 'spec/ol/source/images/zoomify/',
|
||||
size: size
|
||||
});
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
// zoomlevel 0
|
||||
expect(tileUrlFunction([0, 0, -1])).to.eql('spec/ol/source/images/zoomify/TileGroup0/0-0-0.jpg');
|
||||
// zoomlevel 1
|
||||
@@ -268,8 +268,8 @@ describe('ol.source.Zoomify', function() {
|
||||
expect(tileUrlFunction([1, 1, -2])).to.eql('spec/ol/source/images/zoomify/TileGroup0/1-1-1.jpg');
|
||||
});
|
||||
it('returns undefined if no tileCoord passed', function() {
|
||||
var source = getZoomifySource();
|
||||
var tileUrlFunction = source.getTileUrlFunction();
|
||||
const source = getZoomifySource();
|
||||
const tileUrlFunction = source.getTileUrlFunction();
|
||||
expect(tileUrlFunction()).to.be(undefined);
|
||||
});
|
||||
|
||||
@@ -278,37 +278,37 @@ describe('ol.source.Zoomify', function() {
|
||||
describe('uses a custom tileClass', function() {
|
||||
|
||||
it('returns expected tileClass instances via "getTile"', function() {
|
||||
var source = getZoomifySource();
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
const source = getZoomifySource();
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile).to.be.an(Zoomify.Tile_);
|
||||
});
|
||||
|
||||
it('"tile.getImage" returns and caches an unloaded image', function() {
|
||||
var source = getZoomifySource();
|
||||
const source = getZoomifySource();
|
||||
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
var img = tile.getImage();
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
const img = tile.getImage();
|
||||
|
||||
var tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
var img2 = tile2.getImage();
|
||||
const tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
const img2 = tile2.getImage();
|
||||
|
||||
expect(img).to.be.a(HTMLImageElement);
|
||||
expect(img).to.be(img2);
|
||||
});
|
||||
|
||||
it('"tile.getImage" returns and caches a loaded canvas', function(done) {
|
||||
var source = getZoomifySource();
|
||||
const source = getZoomifySource();
|
||||
|
||||
var tile = source.getTile(0, 0, -1, 1, proj);
|
||||
const tile = source.getTile(0, 0, -1, 1, proj);
|
||||
|
||||
_ol_events_.listen(tile, 'change', function() {
|
||||
if (tile.getState() == 2) { // LOADED
|
||||
var img = tile.getImage();
|
||||
const img = tile.getImage();
|
||||
expect(img).to.be.a(HTMLCanvasElement);
|
||||
|
||||
var tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
const tile2 = source.getTile(0, 0, -1, 1, proj);
|
||||
expect(tile2.getState()).to.be(2); // LOADED
|
||||
var img2 = tile2.getImage();
|
||||
const img2 = tile2.getImage();
|
||||
expect(img).to.be(img2);
|
||||
done();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user