Do not rely on remote services for tests
This commit is contained in:
1
test/spec/ol/data/tilejson.json
Normal file
1
test/spec/ol/data/tilejson.json
Normal file
File diff suppressed because one or more lines are too long
@@ -8,9 +8,23 @@ describe('ol.source.TileJSON', function() {
|
|||||||
var source, tileGrid;
|
var source, tileGrid;
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
|
var googNetJsonp = goog.net.Jsonp;
|
||||||
|
// mock goog.net.Jsonp (used in the ol.source.TileJSON constructor)
|
||||||
|
goog.net.Jsonp = function() {
|
||||||
|
this.send = function() {
|
||||||
|
var callback = arguments[1];
|
||||||
|
var client = new XMLHttpRequest();
|
||||||
|
client.open('GET', 'spec/ol/data/tilejson.json', true);
|
||||||
|
client.onload = function() {
|
||||||
|
callback(JSON.parse(client.responseText));
|
||||||
|
};
|
||||||
|
client.send();
|
||||||
|
};
|
||||||
|
};
|
||||||
source = new ol.source.TileJSON({
|
source = new ol.source.TileJSON({
|
||||||
url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp'
|
url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp'
|
||||||
});
|
});
|
||||||
|
goog.net.Jsonp = googNetJsonp;
|
||||||
var key = source.on('change', function() {
|
var key = source.on('change', function() {
|
||||||
if (source.getState() === 'ready') {
|
if (source.getState() === 'ready') {
|
||||||
source.unByKey(key);
|
source.unByKey(key);
|
||||||
@@ -60,5 +74,5 @@ describe('ol.source.TileJSON', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
goog.require('ol.TileCoord');
|
goog.require('goog.net.Jsonp');
|
||||||
goog.require('ol.source.TileJSON');
|
goog.require('ol.source.TileJSON');
|
||||||
|
|||||||
Reference in New Issue
Block a user