From 575c1df524ca8bbcec7cf7d78e10d63af8ab3837 Mon Sep 17 00:00:00 2001 From: Petr Sloup Date: Mon, 27 Jun 2016 08:11:02 +0200 Subject: [PATCH] Add tests for autofit static endpoints --- test/static.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/static.js b/test/static.js index e308e24..2435c4d 100644 --- a/test/static.js +++ b/test/static.js @@ -1,6 +1,9 @@ -var testStatic = function(prefix, q, format, status, scale, type) { +var testStatic = function(prefix, q, format, status, scale, type, query) { if (scale) q += '@' + scale + 'x'; var path = '/styles/' + prefix + '/static/' + q + '.' + format; + if (query) { + path += query; + } it(path + ' returns ' + status, function(done) { var test = supertest(app).get(path); if (status) test.expect(status); @@ -76,4 +79,21 @@ describe('Static endpoints', function() { testStatic('test', '-180,-80,180,80/0.5x2.6', 'png', 404); }); }); + + describe('autofit path', function() { + describe('valid requests', function() { + testStatic('test', 'auto/256x256', 'png', 200, undefined, /image\/png/, '?path=10,10|20,20'); + + describe('different parameters', function() { + testStatic('test', 'auto/20x20', 'png', 200, 2, /image\/png/, '?path=10,10|20,20'); + testStatic('test', 'auto/200x200', 'png', 200, 3, /image\/png/, '?path=-10,-10|-20,-20'); + }); + }); + + describe('invalid requests return 4xx', function() { + testStatic('test', 'auto/256x256', 'png', 400); + testStatic('test', 'auto/256x256', 'png', 400, undefined, undefined, '?path=10,10'); + testStatic('test', 'auto/2560x2560', 'png', 400, undefined, undefined, '?path=10,10|20,20'); + }); + }); });