Add tests

This commit is contained in:
Andreas Hocevar
2015-06-03 12:41:35 +02:00
parent 5ae2521724
commit 5d9708be11
2 changed files with 37 additions and 4 deletions

View File

@@ -148,10 +148,8 @@ ol.tilegrid.TileGrid = function(options) {
}
return tileRange;
}, this);
} else if (goog.isDef(extent)) {
if (!goog.isNull(extent)) {
this.calculateTileRanges_(extent);
}
} else if (goog.isDefAndNotNull(extent)) {
this.calculateTileRanges_(extent);
}
/**

View File

@@ -0,0 +1,35 @@
goog.provide('ol.test.source.TileVector');
describe('ol.source.TileVector', function() {
describe('#loadFeatures()', function() {
it('calls tileUrlFunction with correct tile coords', function() {
var tileCoords = [];
var source = new ol.source.TileVector({
format: new ol.format.TopoJSON(),
projection: 'EPSG:3857',
tileGrid: ol.tilegrid.createXYZ({
maxZoom: 19
}),
tileUrlFunction: function(tileCoord) {
tileCoords.push(tileCoord.slice());
return null;
}
});
source.loadFeatures(
[-8238854, 4969777, -8237854, 4970777], 4.8, source.getProjection());
expect(tileCoords[0]).to.eql([15, 9647, 12320]);
expect(tileCoords[1]).to.eql([15, 9647, 12319]);
expect(tileCoords[2]).to.eql([15, 9648, 12320]);
expect(tileCoords[3]).to.eql([15, 9648, 12319]);
});
});
});
goog.require('ol.format.TopoJSON');
goog.require('ol.source.TileVector');