From 42417cd6fc84d8bfbfb7edaf263073b9af778f9c Mon Sep 17 00:00:00 2001 From: David Manthey Date: Sun, 1 Jan 2017 20:24:21 -0500 Subject: [PATCH] Change how test data is proxied through karma. Eventually, this will facilitate testing examples. --- karma-base.js | 4 ++-- tests/cases/osmLayer.js | 34 +++++++++++++++++----------------- tests/cases/tile.js | 18 +++++++++--------- tests/cases/tileLayer.js | 34 +++++++++++++++++----------------- tests/test-common.js | 6 +++--- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/karma-base.js b/karma-base.js index c2ba6b78c3..9a19d6dbec 100644 --- a/karma-base.js +++ b/karma-base.js @@ -176,8 +176,8 @@ module.exports = { {pattern: 'dist/examples/**/*', included: false} ], proxies: { - '/data/': '/base/tests/data/', - '/distdata/': '/base/dist/data/', + '/testdata/': '/base/tests/data/', + '/data/': '/base/dist/data/', '/examples/': '/base/dist/examples/' }, browsers: [ diff --git a/tests/cases/osmLayer.js b/tests/cases/osmLayer.js index 0ce803f5f0..be29953b2b 100644 --- a/tests/cases/osmLayer.js +++ b/tests/cases/osmLayer.js @@ -126,7 +126,7 @@ describe('geo.core.osmLayer', function () { var layer; it('creation', function () { map = create_map(); - layer = map.createLayer('osm', {renderer: null, url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: null, url: '/testdata/white.jpg'}); expect(map.node().find('[data-tile-layer="0"]').length).toBe(1); }); waitForIt('.geo-tile-container', function () { @@ -137,7 +137,7 @@ describe('geo.core.osmLayer', function () { }); it('mapOpacity', function () { map.deleteLayer(layer); - layer = map.createLayer('osm', {renderer: null, mapOpacity: 0.5, url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: null, mapOpacity: 0.5, url: '/testdata/white.jpg'}); expect(layer.canvas().css('opacity')).toBe('0.5'); }); waitForIt('.geo-tile-container', function () { @@ -159,7 +159,7 @@ describe('geo.core.osmLayer', function () { var layer; it('creation', function () { map = create_map(); - layer = map.createLayer('osm', {renderer: 'd3', url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: 'd3', url: '/testdata/white.jpg'}); }); waitForIt('.d3QuadFeature', function () { return map.node().find('.d3QuadFeature').length > 0; @@ -185,7 +185,7 @@ describe('geo.core.osmLayer', function () { describe('vgl', function () { it('creation', function () { map = create_map(); - map.createLayer('osm', {renderer: 'vgl', url: '/data/white.jpg'}); + map.createLayer('osm', {renderer: 'vgl', url: '/testdata/white.jpg'}); expect(map.node().find('.webgl-canvas').length).toBe(1); }); it('destruction', destroy_map); @@ -194,10 +194,10 @@ describe('geo.core.osmLayer', function () { var layer; it('vgl to null', function () { map = create_map(); - layer = map.createLayer('osm', {renderer: 'vgl', url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: 'vgl', url: '/testdata/white.jpg'}); expect(map.node().find('.webgl-canvas').length).toBe(1); map.deleteLayer(layer); - layer = map.createLayer('osm', {renderer: null, url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: null, url: '/testdata/white.jpg'}); expect(map.node().find('.webgl-canvas').length).toBe(0); expect(map.node().find('[data-tile-layer="0"]').length).toBe(1); }); @@ -207,7 +207,7 @@ describe('geo.core.osmLayer', function () { it('null to d3', function () { expect(map.node().find('[data-tile-layer="0"]').is('div')).toBe(true); map.deleteLayer(layer); - layer = map.createLayer('osm', {renderer: 'd3', url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: 'd3', url: '/testdata/white.jpg'}); expect(map.node().find('[data-tile-layer="0"]').length).toBe(0); }); waitForIt('.d3QuadFeature', function () { @@ -215,14 +215,14 @@ describe('geo.core.osmLayer', function () { }); it('d3 to canvas', function () { map.deleteLayer(layer); - layer = map.createLayer('osm', {renderer: 'canvas', url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: 'canvas', url: '/testdata/white.jpg'}); expect(map.node().find('.d3QuadFature').length).toBe(0); expect(map.node().find('.canvas-canvas').length).toBe(1); }); it('canvas to vgl', function () { expect(map.node().find('.canvas-canvas').length).toBe(1); map.deleteLayer(layer); - layer = map.createLayer('osm', {renderer: 'vgl', url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: 'vgl', url: '/testdata/white.jpg'}); expect(map.node().find('.canvas-canvas').length).toBe(0); expect(map.node().find('.webgl-canvas').length).toBe(1); }); @@ -245,7 +245,7 @@ describe('geo.core.osmLayer', function () { if (angle) { map.rotation(parseFloat(angle) * Math.PI / 180); } - layer = map.createLayer('osm', {renderer: null, url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: null, url: '/testdata/white.jpg'}); expect(map.node().find('[data-tile-layer="0"]').length).toBe(1); }); waitForIt('null tiles to load', function () { @@ -258,7 +258,7 @@ describe('geo.core.osmLayer', function () { positions[ref] = $(this)[0].getBoundingClientRect(); }); map.deleteLayer(layer); - layer = map.createLayer('osm', {renderer: 'd3', url: '/data/white.jpg'}); + layer = map.createLayer('osm', {renderer: 'd3', url: '/testdata/white.jpg'}); expect(map.node().find('[data-tile-layer="0"]').length).toBe(0); }); waitForIt('d3 tiles to load', function () { @@ -292,7 +292,7 @@ describe('geo.core.osmLayer', function () { expect(params.layer.tilesMaxBounds(3)).toEqual({x: 1543, y: 709}); map = create_map(params.map); map.createLayer('osm', $.extend( - {}, params.layer, {renderer: null, url: '/data/white.jpg', zoom: 3})); + {}, params.layer, {renderer: null, url: '/testdata/white.jpg', zoom: 3})); expect(map.node().find('[data-tile-layer="0"]').length).toBe(1); }); waitForIt('.geo-tile-container', function () { @@ -310,7 +310,7 @@ describe('geo.core.osmLayer', function () { mapinfo.map = map; layer = map.createLayer('osm', { renderer: 'd3', - url: '/data/white.jpg' + url: '/testdata/white.jpg' }); }); waitForIt('tiles to load', function () { @@ -340,7 +340,7 @@ describe('geo.core.osmLayer', function () { mapinfo.map = map; layer = map.createLayer('osm', { renderer: 'canvas', - url: '/data/white.jpg' + url: '/testdata/white.jpg' }); }); waitForIt('tiles to load', function () { @@ -368,7 +368,7 @@ describe('geo.core.osmLayer', function () { map = create_map(); layer = map.createLayer('osm', { renderer: 'canvas', - url: '/data/white.jpg', + url: '/testdata/white.jpg', tilesMaxBounds: function (level) { var scale = Math.pow(2, 5 - level); // pick some bounds that could be valid at level 5 @@ -392,7 +392,7 @@ describe('geo.core.osmLayer', function () { mapinfo.map = map; layer = map.createLayer('osm', { renderer: 'vgl', - url: '/data/white.jpg' + url: '/testdata/white.jpg' }); }); waitForIt('tiles to load', function () { @@ -415,7 +415,7 @@ describe('geo.core.osmLayer', function () { map = create_map(); layer = map.createLayer('osm', { renderer: 'vgl', - url: '/data/white.jpg', + url: '/testdata/white.jpg', tilesMaxBounds: function (level) { var scale = Math.pow(2, 5 - level); // pick some bounds that could be valid at level 5 diff --git a/tests/cases/tile.js b/tests/cases/tile.js index 0ec28ed20c..38ef0d7d24 100644 --- a/tests/cases/tile.js +++ b/tests/cases/tile.js @@ -36,7 +36,7 @@ describe('geo.tile', function () { var t = geo.tile({ index: {x: 13, y: 14}, size: {x: 116, y: 117}, - url: '/data/sample.json', + url: '/testdata/sample.json', overlap: {x: 1, y: 3} }); @@ -52,7 +52,7 @@ describe('geo.tile', function () { var t = geo.tile({ index: {x: 0, y: 0}, size: {x: 10, y: 10}, - url: '/data/sample.json' + url: '/testdata/sample.json' }); expect(t.bottom).toEqual(10); @@ -63,7 +63,7 @@ describe('geo.tile', function () { t = geo.tile({ index: {x: 5, y: 6}, size: {x: 10, y: 10}, - url: '/data/sample.json' + url: '/testdata/sample.json' }); expect(t.bottom).toEqual(70); expect(t.left).toEqual(50); @@ -75,7 +75,7 @@ describe('geo.tile', function () { var t = geo.tile({ index: {x: 1, y: 2}, size: {x: 7, y: 11}, - url: '/data/sample.json' + url: '/testdata/sample.json' }); expect(t.bottom).toEqual(33); @@ -91,7 +91,7 @@ describe('geo.tile', function () { var t = geo.tile({ index: {x: 0, y: 0}, size: {x: 10, y: 10}, - url: '/data/sample.json', + url: '/testdata/sample.json', overlap: {x: 1, y: 2} }); @@ -103,7 +103,7 @@ describe('geo.tile', function () { t = geo.tile({ index: {x: 5, y: 6}, size: {x: 10, y: 10}, - url: '/data/sample.json', + url: '/testdata/sample.json', overlap: {x: 1, y: 2} }); expect(t.bottom).toEqual(72); @@ -116,7 +116,7 @@ describe('geo.tile', function () { var t = geo.tile({ index: {x: 1, y: 2}, size: {x: 7, y: 11}, - url: '/data/sample.json', + url: '/testdata/sample.json', overlap: {x: 1, y: 2} }); @@ -133,7 +133,7 @@ describe('geo.tile', function () { var t = geo.tile({ index: {x: 0, y: 0}, size: {x: 10, y: 10}, - url: '/data/sample.json' + url: '/testdata/sample.json' }); var called = false; @@ -177,7 +177,7 @@ describe('geo.tile', function () { t = geo.tile({ index: {x: 1, y: 2}, size: {x: 10, y: 10}, - url: '/data/sample.json' + url: '/testdata/sample.json' }); }); diff --git a/tests/cases/tileLayer.js b/tests/cases/tileLayer.js index fa48382a99..8d4032c72e 100644 --- a/tests/cases/tileLayer.js +++ b/tests/cases/tileLayer.js @@ -375,7 +375,7 @@ describe('geo.tileLayer', function () { expect(l.activeTiles).toEqual({}); }); it('url', function () { - var m = map(), l, mtime, url = '/data/white.jpg'; + var m = map(), l, mtime, url = '/testdata/white.jpg'; opts.map = m; l = geo.tileLayer(opts); expect(l.url() instanceof Function).toBe(true); @@ -599,7 +599,7 @@ describe('geo.tileLayer', function () { topDown: true, wrapX: false, wrapY: false, - url: function () { return '/data/white.jpg'; } + url: function () { return '/testdata/white.jpg'; } }); expect(l.cache.size).toBe(2); @@ -615,7 +615,7 @@ describe('geo.tileLayer', function () { }); }); it('prefetch', function (done) { - var l = geo.tileLayer({map: map(), url: function () { return '/data/white.jpg'; }}), + var l = geo.tileLayer({map: map(), url: function () { return '/testdata/white.jpg'; }}), d1 = new $.Deferred(), d2 = new $.Deferred(); @@ -1224,7 +1224,7 @@ describe('geo.tileLayer', function () { wrapX: false, wrapY: false, topDown: true, - url: function () { return '/data/white.jpg'; } + url: function () { return '/testdata/white.jpg'; } }); tiles = l._getTiles(1, {left: 50, right: 500, bottom: 500, top: 50}, true); @@ -1239,7 +1239,7 @@ describe('geo.tileLayer', function () { wrapX: false, wrapY: false, topDown: true, - url: function () { return '/data/white.jpg'; } + url: function () { return '/testdata/white.jpg'; } }); tiles = l._getTiles(0, {left: 50, right: 500, bottom: 500, top: 50}); @@ -1254,7 +1254,7 @@ describe('geo.tileLayer', function () { wrapX: true, wrapY: false, topDown: true, - url: function () { return '/data/white.jpg'; } + url: function () { return '/testdata/white.jpg'; } }); tiles = l._getTiles(0, {left: 50, right: 500, bottom: 500, top: 50}); @@ -1270,7 +1270,7 @@ describe('geo.tileLayer', function () { wrapX: false, wrapY: true, topDown: true, - url: function () { return '/data/white.jpg'; } + url: function () { return '/testdata/white.jpg'; } }); tiles = l._getTiles(0, {left: 50, right: 500, bottom: 500, top: 50}); @@ -1286,7 +1286,7 @@ describe('geo.tileLayer', function () { wrapX: true, wrapY: true, topDown: true, - url: function () { return '/data/white.jpg'; } + url: function () { return '/testdata/white.jpg'; } }); tiles = l._getTiles(0, {left: 50, right: 500, bottom: 500, top: 50}); @@ -1301,7 +1301,7 @@ describe('geo.tileLayer', function () { wrapX: false, wrapY: false, topDown: true, - url: '/data/white.jpg?s={s}&x={x}&y={y}&z={z}' + url: '/testdata/white.jpg?s={s}&x={x}&y={y}&z={z}' }); tiles = l._getTiles(1, {left: 50, right: 500, bottom: 500, top: 50}); @@ -1319,7 +1319,7 @@ describe('geo.tileLayer', function () { wrapX: false, wrapY: false, topDown: true, - baseUrl: '/data/white.jpg?test=' + baseUrl: '/testdata/white.jpg?test=' }); tiles = l._getTiles(1, {left: 50, right: 500, bottom: 500, top: 50}); @@ -1370,7 +1370,7 @@ describe('geo.tileLayer', function () { describe('drawTile', function () { function test_draw(tile) { - var l = layer_html({url: function () { return '/data/white.jpg'; }}); + var l = layer_html({url: function () { return '/testdata/white.jpg'; }}); l.drawTile(l._getTileCached(tile)); l.drawTile(l._getTileCached(tile)); // draw it twice, but should only add one return l; @@ -1432,7 +1432,7 @@ describe('geo.tileLayer', function () { var l = layer_html({url: function () { return 'not a valid url'; }}), t; t = l._getTileCached({x: 0, y: 0, level: 0}); - t.image = $('').get(0); + t.image = $('').get(0); l.drawTile(t); t.catch(spy); @@ -1447,7 +1447,7 @@ describe('geo.tileLayer', function () { it('cropped tile', function () { var w = 5602, h = 4148; var l = layer_html({ - url: function () { return '/data/white.jpg'; }, + url: function () { return '/testdata/white.jpg'; }, tilesMaxBounds: function (level) { var scale = Math.pow(2, 5 - level); return { @@ -1468,7 +1468,7 @@ describe('geo.tileLayer', function () { function setup(bds, opts) { var l = layer_html($.extend( - true, {url: function () { return '/data/white.jpg'; }}, opts || {})); + true, {url: function () { return '/testdata/white.jpg'; }}, opts || {})); l._getViewBounds = function () { return bds || { left: -50, @@ -1543,7 +1543,7 @@ describe('geo.tileLayer', function () { }); }); it('clear all tiles', function () { - var l = layer_html({url: function () { return '/data/white.jpg'; }}), tiles; + var l = layer_html({url: function () { return '/testdata/white.jpg'; }}), tiles; tiles = [ l._getTileCached({x: 0, y: 0, level: 0}), @@ -1562,7 +1562,7 @@ describe('geo.tileLayer', function () { expect(l.cache.length).toBe(5); }); it('reset the layer', function () { - var l = layer_html({url: function () { return '/data/white.jpg'; }}), tiles; + var l = layer_html({url: function () { return '/testdata/white.jpg'; }}), tiles; tiles = [ l._getTileCached({x: 0, y: 0, level: 0}), @@ -1583,7 +1583,7 @@ describe('geo.tileLayer', function () { }); it('Overloading draw method', function () { - var l = geo.tileLayer({map: map(), url: function () { return '/data/white.jpg'; }}), + var l = geo.tileLayer({map: map(), url: function () { return '/testdata/white.jpg'; }}), called = 0; l._drawTile = function () { called += 1; }; l.drawTile(l._getTile({x: 0, y: 0, level: 0})); diff --git a/tests/test-common.js b/tests/test-common.js index d29a15aa08..39c383a13c 100644 --- a/tests/test-common.js +++ b/tests/test-common.js @@ -28,13 +28,13 @@ module.exports = { $.extend(true, mapDefaults, mapOpts); var osmDefaults = { - baseUrl: '/data/tiles/', + baseUrl: '/testdata/tiles/', attribution: null }; if (notiles) { osmDefaults.url = function () { - return '/data/white.jpg'; + return '/testdata/white.jpg'; }; delete osmDefaults.baseUrl; } @@ -72,7 +72,7 @@ module.exports = { // Load at most n rows of the cities dataset. $.ajax({ type: 'GET', - url: '/distdata/cities.csv', + url: '/data/cities.csv', dataType: 'text', success: function (data) { function processCSVData(csvdata) {