Each error-case will have different expectations

This commit is contained in:
Raul Ochoa 2016-04-21 17:27:20 +02:00
parent c5bed48d61
commit a11c8d882e

View File

@ -4,7 +4,7 @@ var assert = require('../../support/assert');
var TestClient = require('../../support/test-client'); var TestClient = require('../../support/test-client');
describe('analysis-layers error cases', function() { describe('analysis-layers error cases', function() {
function mapConfig(layers, dataviews, analysis) { function createMapConfig(layers, dataviews, analysis) {
return { return {
version: '1.5.0', version: '1.5.0',
layers: layers, layers: layers,
@ -13,12 +13,15 @@ describe('analysis-layers error cases', function() {
}; };
} }
var useCases = [ var ERROR_RESPONSE = {
{ status: 400,
desc: 'invalid source.id in layer', headers: {
fixture: 'buffer-over-source.png', 'Content-Type': 'application/json; charset=utf-8'
tile: { z: 7, x: 61, y: 47 }, }
mapConfig: mapConfig( };
it('should handle missing analysis nodes for layers', function(done) {
var mapConfig = createMapConfig(
[ [
{ {
"type": "cartodb", "type": "cartodb",
@ -48,21 +51,9 @@ describe('analysis-layers error cases', function() {
} }
} }
] ]
) );
}
];
var ERROR_RESPONSE = { var testClient = new TestClient(mapConfig, 1234);
status: 400,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
};
useCases.forEach(function(useCase) {
it('should implement use case: "' + useCase.desc + '"', function(done) {
var testClient = new TestClient(useCase.mapConfig, 1234);
testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) { testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroupResult) {
assert.ok(!err, err); assert.ok(!err, err);
@ -74,4 +65,3 @@ describe('analysis-layers error cases', function() {
}); });
}); });
}); });
});