From 2ff410946aa0acc4f904e7654db65e932503dd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 17 Apr 2018 11:20:15 +0200 Subject: [PATCH] Add test to check that the regexp validates just digits --- .../cartodb/middlewares/coordinates.test.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/unit/cartodb/middlewares/coordinates.test.js b/test/unit/cartodb/middlewares/coordinates.test.js index be84a8e9..43eb4a6c 100644 --- a/test/unit/cartodb/middlewares/coordinates.test.js +++ b/test/unit/cartodb/middlewares/coordinates.test.js @@ -44,6 +44,28 @@ describe('coordinates middleware', function () { }); }); + it('should return error: invalid zoom paramenter (0.1)', function (done) { + const coords = coordinates(); + const req = { + params: { + z: '0.1', + x: '0', + y: '0' + } + }; + const res = {}; + + coords(req, res, function (err) { + assert.equal( + err.message, + 'Invalid zoom value (0.1). It should be an integer number greather or equal to 0' + ); + assert.equal(err.http_status, 400); + done(); + }); + }); + + it('should return error: invalid zoom paramenter (wadus)', function (done) { const coords = coordinates(); const req = {