static image format tests

This commit is contained in:
Simon Martín
2018-05-11 17:41:26 +02:00
parent 7112341c51
commit db7b4fa937
2 changed files with 88 additions and 0 deletions

View File

@@ -261,6 +261,41 @@ describe('named-maps analysis', function() {
);
});
it('should return and an error requesting unsupported image format', function(done) {
assert.response(
server,
{
url: '/api/v1/map/static/center/' + layergroupid + '/4/42/-3/320/240.gif',
method: 'GET',
encoding: 'binary',
headers: {
host: username
}
},
{
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
},
function(res, err) {
assert.ifError(err);
assert.deepEqual(
JSON.parse(res.body),
{
errors:['Unsupported image format \"gif\"'],
errors_with_context:[{
type: 'unknown',
message: 'Unsupported image format \"gif\"'
}]
}
);
done();
}
);
});
});
describe('auto-instantiation', function() {

View File

@@ -282,4 +282,57 @@ describe('named maps static view', function() {
});
});
it('should return an error requesting unsupported image format', function (done) {
var view = {
zoom: 4,
center: {
lng: 40,
lat: 20
}
};
templateMaps.addTemplate(username, createTemplate(view), function (err) {
if (err) {
return done(err);
}
var url = `/api/v1/map/static/named/${templateName}/640/480.gif`;
var requestOptions = {
url: url,
method: 'GET',
headers: {
host: username
},
encoding: 'binary'
};
var expectedResponse = {
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
// this could be removed once named maps are invalidated, otherwise you hits the cache
var server = new CartodbWindshaft(serverOptions);
assert.response(server, requestOptions, expectedResponse, function (res, err) {
assert.ifError(err);
assert.deepEqual(
JSON.parse(res.body),
{
errors:['Unsupported image format \"gif\"'],
errors_with_context:[{
type: 'unknown',
message: 'Unsupported image format \"gif\"'
}]
}
);
done();
});
});
});
});