Add and fix tiles_rendered tests

This commit is contained in:
Petteri Pesonen 2020-11-17 12:32:28 +02:00 committed by Andrew Calcutt
parent 6d89332c8d
commit c1117de4a7

View file

@ -1,8 +1,8 @@
const testTile = function (prefix, z, x, y, format, status, scale, type) { var testTile = function(prefix, tileSize = 256, z, x, y, format, status, scale, type) {
if (scale) y += '@' + scale + 'x'; if (scale) y += '@' + scale + 'x';
const path = '/styles/' + prefix + '/' + z + '/' + x + '/' + y + '.' + format; var path = '/styles/' + prefix + '/' + tileSize + '/' + z + '/' + x + '/' + y + '.' + format;
it(path + ' returns ' + status, function (done) { it(path + ' returns ' + status, function(done) {
const test = supertest(app).get(path); var test = supertest(app).get(path);
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);
@ -11,35 +11,45 @@ const testTile = function (prefix, z, x, y, format, status, scale, type) {
const prefix = 'test-style'; const prefix = 'test-style';
describe('Raster tiles', function () { describe('Raster tiles', function() {
describe('valid requests', function () { describe('valid requests', function() {
describe('various formats', function () { describe('various formats', function() {
testTile(prefix, 0, 0, 0, 'png', 200, undefined, /image\/png/); testTile(prefix, 256, 0, 0, 0, 'png', 200, undefined, /image\/png/);
testTile(prefix, 0, 0, 0, 'jpg', 200, undefined, /image\/jpeg/); testTile(prefix, 512, 0, 0, 0, 'png', 200, undefined, /image\/png/);
testTile(prefix, 0, 0, 0, 'jpeg', 200, undefined, /image\/jpeg/); testTile(prefix, 256, 0, 0, 0, 'jpg', 200, undefined, /image\/jpeg/);
testTile(prefix, 0, 0, 0, 'webp', 200, undefined, /image\/webp/); testTile(prefix, 512, 0, 0, 0, 'jpg', 200, undefined, /image\/jpeg/);
testTile(prefix, 256, 0, 0, 0, 'jpeg', 200, undefined, /image\/jpeg/);
testTile(prefix, 512, 0, 0, 0, 'jpeg', 200, undefined, /image\/jpeg/);
testTile(prefix, 256, 0, 0, 0, 'webp', 200, undefined, /image\/webp/);
testTile(prefix, 512, 0, 0, 0, 'webp', 200, undefined, /image\/webp/);
}); });
describe('different coordinates and scales', function () { describe('different coordinates and scales', function() {
testTile(prefix, 1, 1, 1, 'png', 200); testTile(prefix, 256, 1, 1, 1, 'png', 200);
testTile(prefix, 512, 0, 0, 0, 'png', 200);
testTile(prefix, 0, 0, 0, 'png', 200, 2); testTile(prefix, 256, 0, 0, 0, 'png', 200, 2);
testTile(prefix, 0, 0, 0, 'png', 200, 3); testTile(prefix, 512, 0, 0, 0, 'png', 200, 2);
testTile(prefix, 2, 1, 1, 'png', 200, 3); testTile(prefix, 256, 0, 0, 0, 'png', 200, 3);
testTile(prefix, 512, 0, 0, 0, 'png', 200, 3);
testTile(prefix, 256, 2, 1, 1, 'png', 200, 3);
testTile(prefix, 512, 2, 1, 1, 'png', 200, 3);
}); });
}); });
describe('invalid requests return 4xx', function () { describe('invalid requests return 4xx', function() {
testTile('non_existent', 0, 0, 0, 'png', 404); testTile('non_existent', 256, 0, 0, 0, 'png', 404);
testTile(prefix, -1, 0, 0, 'png', 404); testTile(prefix, 256, -1, 0, 0, 'png', 404);
testTile(prefix, 25, 0, 0, 'png', 404); testTile(prefix, 256, 25, 0, 0, 'png', 404);
testTile(prefix, 0, 1, 0, 'png', 404); testTile(prefix, 256, 0, 1, 0, 'png', 404);
testTile(prefix, 0, 0, 1, 'png', 404); testTile(prefix, 256, 0, 0, 1, 'png', 404);
testTile(prefix, 0, 0, 0, 'gif', 400); testTile(prefix, 256, 0, 0, 0, 'gif', 400);
testTile(prefix, 0, 0, 0, 'pbf', 400); testTile(prefix, 256, 0, 0, 0, 'pbf', 400);
testTile(prefix, 0, 0, 0, 'png', 404, 1); testTile(prefix, 256, 0, 0, 0, 'png', 404, 1);
testTile(prefix, 0, 0, 0, 'png', 404, 5); testTile(prefix, 256, 0, 0, 0, 'png', 404, 5);
testTile(prefix, 300, 0, 0, 0, 'png', 404);
// testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this // testTile('hybrid', 0, 0, 0, 'png', 404); //TODO: test this
}); });