diff --git a/test/acceptance/dataviews/histogram.js b/test/acceptance/dataviews/histogram.js index 5d5ff000..abbaef61 100644 --- a/test/acceptance/dataviews/histogram.js +++ b/test/acceptance/dataviews/histogram.js @@ -77,4 +77,24 @@ describe('histogram-dataview', function() { done(); }); }); + + it('should cast all overridable params to numbers', function(done) { + var params = { + bins: '256 AS other, (select 256 * 2) AS bins_number--', + start: 1e3, + end: 0, + response: TestClient.RESPONSE.ERROR + }; + + this.testClient = new TestClient(mapConfig, 1234); + this.testClient.getDataview('pop_max_histogram', params, function(err, res) { + assert.ok(!err, err); + + assert.ok(res.errors); + assert.equal(res.errors.length, 1); + assert.ok(res.errors[0].match(/Invalid number format for parameter 'bins'/)); + + done(); + }); + }); }); diff --git a/test/support/test-client.js b/test/support/test-client.js index f5d3789c..75fa51e0 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -307,6 +307,13 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) { url += '?' + qs.stringify(extraParams); } + var expectedResponse = params.response || { + status: 200, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }; + var layergroupId; step( function createLayergroup() { @@ -372,12 +379,7 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) { host: 'localhost' } }, - { - status: 200, - headers: { - 'Content-Type': 'application/json; charset=utf-8' - } - }, + expectedResponse, function(res, err) { if (err) { return next(err);