More tests for the endpoints
This commit is contained in:
parent
9736649244
commit
d6e17c1a3a
4 changed files with 103 additions and 7 deletions
|
@ -16,4 +16,22 @@ describe('Metadata', function() {
|
||||||
}).end(done);
|
}).end(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('/test/index.json', function() {
|
||||||
|
it('is json', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get('/test/index.json')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Content-Type', /application\/json/, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has valid basename and tiles', function(done) {
|
||||||
|
supertest(app)
|
||||||
|
.get('/test/index.json')
|
||||||
|
.expect(function(res) {
|
||||||
|
res.body.basename.should.equal('test');
|
||||||
|
res.body.tiles.length.should.be.greaterThan(0);
|
||||||
|
}).end(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
40
test/static.js
Normal file
40
test/static.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
var testStatic = function(prefix, q, format, status, scale, type) {
|
||||||
|
if (scale) q += '@' + scale + 'x';
|
||||||
|
var path = '/' + prefix + '/static/' + q + '.' + format;
|
||||||
|
it(path + ' returns ' + status, function(done) {
|
||||||
|
var test = supertest(app).get(path);
|
||||||
|
if (status) test.expect(status);
|
||||||
|
if (type) test.expect('Content-Type', type);
|
||||||
|
test.end(done);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Static endpoints', function() {
|
||||||
|
describe('center-based', function() {
|
||||||
|
describe('Valid requests', function() {
|
||||||
|
testStatic('test', '0,0,0/256x256', 'png', 200, undefined, /image\/png/);
|
||||||
|
testStatic('test', '0,0,0/256x256', 'jpg', 200, undefined, /image\/jpeg/);
|
||||||
|
testStatic('test', '0,0,0/256x256', 'jpeg', 200, undefined, /image\/jpeg/);
|
||||||
|
testStatic('test', '0,0,0/256x256', 'webp', 200, undefined, /image\/webp/);
|
||||||
|
|
||||||
|
testStatic('test', '0,0,0/300x300', 'png', 200, 2);
|
||||||
|
testStatic('test', '0,0,0/300x300', 'png', 200, 3);
|
||||||
|
|
||||||
|
testStatic('test', '80,40,20/600x300', 'png', 200, 3);
|
||||||
|
testStatic('test', '8.5,40.5,20/300x150', 'png', 200, 3);
|
||||||
|
testStatic('test', '-8.5,-40.5,20/300x150', 'png', 200, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Invalid requests', function() {
|
||||||
|
testStatic('test', '190,0,0/256x256', 'png', 400);
|
||||||
|
testStatic('test', '0,86,0/256x256', 'png', 400);
|
||||||
|
testStatic('test', '80,40,20/0x0', 'png', 400);
|
||||||
|
testStatic('test', '0,0,0/256x256', 'gif', 400);
|
||||||
|
testStatic('test', '0,0,0/256x256', 'png', 404, 1);
|
||||||
|
|
||||||
|
testStatic('test', '0,0,-1/256x256', 'png', 404);
|
||||||
|
testStatic('test', '0,0,1.5/256x256', 'png', 404);
|
||||||
|
testStatic('test', '0,0,0/256.5x256.5', 'png', 404);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,8 +1,9 @@
|
||||||
var testTile = function(prefix, z, x, y, format, status, type) {
|
var testTile = function(prefix, z, x, y, format, status, scale, type) {
|
||||||
|
if (scale) y += '@' + scale + 'x';
|
||||||
var path = '/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format;
|
var path = '/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format;
|
||||||
it(path + ' returns ' + status, function(done) {
|
it(path + ' returns ' + status, function(done) {
|
||||||
var test = supertest(app).get(path);
|
var test = supertest(app).get(path);
|
||||||
if (status) test.expect(status);
|
test.expect(status);
|
||||||
if (type) test.expect('Content-Type', type);
|
if (type) test.expect('Content-Type', type);
|
||||||
test.end(done);
|
test.end(done);
|
||||||
});
|
});
|
||||||
|
@ -10,19 +11,28 @@ var testTile = function(prefix, z, x, y, format, status, type) {
|
||||||
|
|
||||||
describe('Raster tiles', function() {
|
describe('Raster tiles', function() {
|
||||||
describe('existing tiles', function() {
|
describe('existing tiles', function() {
|
||||||
testTile('test', 0, 0, 0, 'png', 200, /image\/png/);
|
testTile('test', 0, 0, 0, 'png', 200, undefined, /image\/png/);
|
||||||
testTile('test', 0, 0, 0, 'jpg', 200, /image\/jpeg/);
|
testTile('test', 0, 0, 0, 'jpg', 200, undefined, /image\/jpeg/);
|
||||||
testTile('test', 0, 0, 0, 'jpeg', 200, /image\/jpeg/);
|
testTile('test', 0, 0, 0, 'jpeg', 200, undefined, /image\/jpeg/);
|
||||||
testTile('test', 0, 0, 0, 'webp', 200, /image\/webp/);
|
testTile('test', 0, 0, 0, 'webp', 200, undefined, /image\/webp/);
|
||||||
|
|
||||||
testTile('test', 1, 1, 1, 'png', 200);
|
testTile('test', 1, 1, 1, 'png', 200);
|
||||||
|
|
||||||
|
testTile('test', 0, 0, 0, 'png', 200, 2);
|
||||||
|
testTile('test', 0, 0, 0, 'png', 200, 3);
|
||||||
|
testTile('test', 2, 1, 1, 'png', 200, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('error tiles', function() {
|
describe('error tiles', function() {
|
||||||
testTile('non_existent', 0, 0, 0, 'png', 404);
|
testTile('non_existent', 0, 0, 0, 'png', 404);
|
||||||
testTile('test', -1, 0, 0, 'png', 404);
|
testTile('test', -1, 0, 0, 'png', 404);
|
||||||
|
testTile('test', 25, 0, 0, 'png', 404);
|
||||||
testTile('test', 0, 1, 0, 'png', 404);
|
testTile('test', 0, 1, 0, 'png', 404);
|
||||||
testTile('test', 0, 0, 1, 'png', 404);
|
testTile('test', 0, 0, 1, 'png', 404);
|
||||||
testTile('test', 0, 0, 1, 'gif', 404);
|
testTile('test', 0, 0, 0, 'gif', 400);
|
||||||
|
testTile('test', 0, 0, 0, 'pbf', 400);
|
||||||
|
|
||||||
|
testTile('test', 0, 0, 0, 'png', 404, 1);
|
||||||
|
testTile('test', 0, 0, 0, 'png', 404, 4);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
28
test/tiles_vector.js
Normal file
28
test/tiles_vector.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
var testTile = function(prefix, z, x, y, status) {
|
||||||
|
var path = '/' + prefix + '/' + z + '/' + x + '/' + y + '.pbf';
|
||||||
|
it(path + ' returns ' + status, function(done) {
|
||||||
|
var test = supertest(app).get(path);
|
||||||
|
if (status) test.expect(status);
|
||||||
|
if (status == 200) test.expect('Content-Type', /application\/x-protobuf/);
|
||||||
|
test.end(done);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var prefix = 'zurich-vector';
|
||||||
|
|
||||||
|
describe('Vector tiles', function() {
|
||||||
|
describe('existing tiles', function() {
|
||||||
|
testTile(prefix, 0, 0, 0, 200);
|
||||||
|
testTile(prefix, 14, 8581, 5738, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('error tiles', function() {
|
||||||
|
testTile('non_existent', 0, 0, 0, 404);
|
||||||
|
testTile(prefix, -1, 0, 0, 404); // err zoom
|
||||||
|
testTile(prefix, 20, 0, 0, 404); // zoom out of bounds
|
||||||
|
testTile(prefix, 0, 1, 0, 404);
|
||||||
|
testTile(prefix, 0, 0, 1, 404);
|
||||||
|
|
||||||
|
testTile(prefix, 14, 0, 0, 404); // non existent tile
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue