Skip to content

Commit

Permalink
Change how test data is proxied through karma.
Browse files Browse the repository at this point in the history
Eventually, this will facilitate testing examples.
  • Loading branch information
manthey committed Jan 2, 2017
1 parent 8bce80d commit 42417cd
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions karma-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
34 changes: 17 additions & 17 deletions tests/cases/osmLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
});
Expand All @@ -207,22 +207,22 @@ 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 () {
return map.node().find('.d3QuadFeature').length > 0;
});
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);
});
Expand All @@ -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 () {
Expand All @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand All @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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
Expand All @@ -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 () {
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions tests/cases/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
});

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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}
});

Expand All @@ -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);
Expand All @@ -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}
});

Expand All @@ -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;
Expand Down Expand Up @@ -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'
});
});

Expand Down
34 changes: 17 additions & 17 deletions tests/cases/tileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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});
Expand All @@ -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});
Expand All @@ -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});
Expand All @@ -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});
Expand All @@ -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});
Expand All @@ -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});
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = $('<img src="/data/white.jpg"/>').get(0);
t.image = $('<img src="/testdata/white.jpg"/>').get(0);
l.drawTile(t);
t.catch(spy);

Expand All @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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}),
Expand All @@ -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}),
Expand All @@ -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}));
Expand Down
Loading

0 comments on commit 42417cd

Please sign in to comment.