testing X-Tiler-Errors existence
This commit is contained in:
parent
605d7057c9
commit
8cf878f723
@ -3,7 +3,7 @@ require('../../support/test_helper.js');
|
||||
var assert = require('assert');
|
||||
var errorMiddleware = require('../../../lib/cartodb/middleware/error-middleware');
|
||||
|
||||
describe('error-middleware', function() {
|
||||
describe.only('error-middleware', function() {
|
||||
|
||||
it('different formats for postgis plugin error returns 400 as status code', function() {
|
||||
|
||||
@ -20,4 +20,38 @@ describe('error-middleware', function() {
|
||||
"Error status code for multiline/PSQL does not match"
|
||||
);
|
||||
});
|
||||
|
||||
it('should return a header with errors', function (done) {
|
||||
const error = new Error('error test');
|
||||
|
||||
const req = {};
|
||||
const res = {
|
||||
headers: {},
|
||||
set (key, value) {
|
||||
this.headers[key] = value;
|
||||
},
|
||||
statusCode: 0,
|
||||
status (status) {
|
||||
this.statusCode = status;
|
||||
},
|
||||
json () {},
|
||||
send () {}
|
||||
};
|
||||
|
||||
const errorHeader = {
|
||||
statusCode: 400,
|
||||
message: error.message,
|
||||
name: error.name,
|
||||
moreErrors: []
|
||||
};
|
||||
|
||||
const errorFn = errorMiddleware();
|
||||
errorFn(error, req, res);
|
||||
|
||||
assert.deepEqual(res.headers, {
|
||||
'X-Tiler-Errors': JSON.stringify(errorHeader)
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user