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