Add test to validate bins param is casted as Number

This commit is contained in:
Raul Ochoa 2017-02-02 16:12:49 +01:00
parent f69f999694
commit 281588abd2
2 changed files with 28 additions and 6 deletions

View File

@ -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();
});
});
});

View File

@ -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);