diff --git a/test/spec/ol/data/tilejson.json b/test/spec/ol/data/tilejson.json new file mode 100644 index 0000000000..83c495eefe --- /dev/null +++ b/test/spec/ol/data/tilejson.json @@ -0,0 +1 @@ +{"attribution":"","bounds":[-180,-85.05112877980659,180,85.05112877980659],"center":[0,0,4],"description":"One of the example maps that comes with TileMill - a bright & colorful world map that blends retro and high-tech with its folded paper texture and interactive flag tooltips. ","download":"http://a.tiles.mapbox.com/v3/mapbox.geography-class.mbtiles","embed":"http://a.tiles.mapbox.com/v3/mapbox.geography-class.html","filesize":134727680,"grids":["http://a.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.grid.json","http://b.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.grid.json"],"id":"mapbox.geography-class","legend":"
\n\n
Geography Class
\n
by MapBox
\n\n\n
","maxzoom":8,"minzoom":0,"name":"Geography Class","private":false,"scheme":"xyz","template":"{{#__location__}}{{/__location__}}{{#__teaser__}}
\n\n
\n{{admin}}\n\n
{{/__teaser__}}{{#__full__}}{{/__full__}}","tilejson":"2.0.0","tiles":["http://a.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png","http://b.tiles.mapbox.com/v3/mapbox.geography-class/{z}/{x}/{y}.png"],"version":"1.0.0","webpage":"http://a.tiles.mapbox.com/v3/mapbox.geography-class/page.html"} diff --git a/test/spec/ol/source/tilejsonsource.test.js b/test/spec/ol/source/tilejsonsource.test.js index 47148afadb..62d9254237 100644 --- a/test/spec/ol/source/tilejsonsource.test.js +++ b/test/spec/ol/source/tilejsonsource.test.js @@ -8,9 +8,23 @@ describe('ol.source.TileJSON', function() { var source, tileGrid; 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({ url: 'http://api.tiles.mapbox.com/v3/mapbox.geography-class.jsonp' }); + goog.net.Jsonp = googNetJsonp; var key = source.on('change', function() { if (source.getState() === 'ready') { 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');