Use class keyword in tests
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import {inherits} from '../../../../src/ol/index.js';
|
||||
import View from '../../../../src/ol/View.js';
|
||||
import Event from '../../../../src/ol/events/Event.js';
|
||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||
@@ -94,14 +93,16 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||
beforeEach(function() {
|
||||
OrigFileReader = FileReader;
|
||||
|
||||
FileReader = function() {
|
||||
EventTarget.apply(this, arguments);
|
||||
this.readAsText = function(file) {
|
||||
class MockFileReader extends EventTarget {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
}
|
||||
readAsText(file) {
|
||||
this.result = file;
|
||||
this.dispatchEvent('load');
|
||||
};
|
||||
};
|
||||
inherits(FileReader, EventTarget);
|
||||
}
|
||||
}
|
||||
FileReader = MockFileReader;
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
||||
@@ -59,14 +59,15 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
||||
feature2 = new Feature(new Point([0, 0]));
|
||||
feature3 = new RenderFeature('Point', [1, -1], []);
|
||||
feature2.setStyle(featureStyle);
|
||||
const TileClass = function() {
|
||||
VectorTile.apply(this, arguments);
|
||||
this.setState(TileState.LOADED);
|
||||
this.setFeatures([feature1, feature2, feature3]);
|
||||
this.setProjection(getProjection('EPSG:4326'));
|
||||
tileCallback(this);
|
||||
};
|
||||
inherits(TileClass, VectorTile);
|
||||
class TileClass extends VectorTile {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.setState(TileState.LOADED);
|
||||
this.setFeatures([feature1, feature2, feature3]);
|
||||
this.setProjection(getProjection('EPSG:4326'));
|
||||
tileCallback(this);
|
||||
}
|
||||
}
|
||||
source = new VectorTileSource({
|
||||
format: new MVT(),
|
||||
tileClass: TileClass,
|
||||
@@ -291,23 +292,24 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
|
||||
|
||||
describe('#forEachFeatureAtCoordinate', function() {
|
||||
let layer, renderer, replayGroup;
|
||||
const TileClass = function() {
|
||||
VectorImageTile.apply(this, arguments);
|
||||
this.extent = [-Infinity, -Infinity, Infinity, Infinity];
|
||||
this.setState(TileState.LOADED);
|
||||
const sourceTile = new VectorTile([0, 0, 0]);
|
||||
sourceTile.setState(TileState.LOADED);
|
||||
sourceTile.setProjection(getProjection('EPSG:3857'));
|
||||
sourceTile.getReplayGroup = function() {
|
||||
return replayGroup;
|
||||
};
|
||||
const key = sourceTile.tileCoord.toString();
|
||||
this.tileKeys = [key];
|
||||
this.sourceTiles_ = {};
|
||||
this.sourceTiles_[key] = sourceTile;
|
||||
this.wrappedTileCoord = arguments[0];
|
||||
};
|
||||
inherits(TileClass, VectorImageTile);
|
||||
class TileClass extends VectorImageTile {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.extent = [-Infinity, -Infinity, Infinity, Infinity];
|
||||
this.setState(TileState.LOADED);
|
||||
const sourceTile = new VectorTile([0, 0, 0]);
|
||||
sourceTile.setState(TileState.LOADED);
|
||||
sourceTile.setProjection(getProjection('EPSG:3857'));
|
||||
sourceTile.getReplayGroup = function() {
|
||||
return replayGroup;
|
||||
};
|
||||
const key = sourceTile.tileCoord.toString();
|
||||
this.tileKeys = [key];
|
||||
this.sourceTiles_ = {};
|
||||
this.sourceTiles_[key] = sourceTile;
|
||||
this.wrappedTileCoord = arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
replayGroup = {};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {inherits} from '../../../../src/ol/index.js';
|
||||
import Tile from '../../../../src/ol/Tile.js';
|
||||
import TileRange from '../../../../src/ol/TileRange.js';
|
||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||
@@ -16,24 +15,24 @@ import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
|
||||
* @param {Object.<string, ol.TileState>} tileStates Lookup of tile key to
|
||||
* tile state.
|
||||
*/
|
||||
const MockTile = function(tileStates) {
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
|
||||
origin: [-180, -180],
|
||||
tileSize: 256
|
||||
});
|
||||
class MockTile extends TileSource {
|
||||
constructor(tileStates) {
|
||||
const tileGrid = new TileGrid({
|
||||
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
|
||||
origin: [-180, -180],
|
||||
tileSize: 256
|
||||
});
|
||||
|
||||
TileSource.call(this, {
|
||||
projection: getProjection('EPSG:4326'),
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
super({
|
||||
projection: getProjection('EPSG:4326'),
|
||||
tileGrid: tileGrid
|
||||
});
|
||||
|
||||
for (const key in tileStates) {
|
||||
this.tileCache.set(key, new Tile(key.split('/'), tileStates[key]));
|
||||
for (const key in tileStates) {
|
||||
this.tileCache.set(key, new Tile(key.split('/'), tileStates[key]));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
inherits(MockTile, TileSource);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user