Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('discards es.NotFound errors and returns a generic NotFound error', () => {
const error = new esErrors.NotFound();
expect(isNotFoundError(error)).to.be(false);
const genericError = decorateEsError(error);
expect(genericError).to.not.be(error);
expect(isNotFoundError(error)).to.be(false);
expect(isNotFoundError(genericError)).to.be(true);
});
it('should transform elasticsearch errors into boom errors with the same status code', function () {
const conflict = handleESError(new esErrors.Conflict());
expect(conflict.isBoom).to.be(true);
expect(conflict.output.statusCode).to.be(409);
const forbidden = handleESError(new esErrors[403]);
expect(forbidden.isBoom).to.be(true);
expect(forbidden.output.statusCode).to.be(403);
const notFound = handleESError(new esErrors.NotFound());
expect(notFound.isBoom).to.be(true);
expect(notFound.output.statusCode).to.be(404);
const badRequest = handleESError(new esErrors.BadRequest());
expect(badRequest.isBoom).to.be(true);
expect(badRequest.output.statusCode).to.be(400);
});
it('should transform elasticsearch errors into boom errors with the same status code', function () {
var conflict = handleESError(new esErrors.Conflict());
expect(conflict.isBoom).to.be(true);
expect(conflict.output.statusCode).to.be(409);
var forbidden = handleESError(new esErrors[403]);
expect(forbidden.isBoom).to.be(true);
expect(forbidden.output.statusCode).to.be(403);
var notFound = handleESError(new esErrors.NotFound());
expect(notFound.isBoom).to.be(true);
expect(notFound.output.statusCode).to.be(404);
var badRequest = handleESError(new esErrors.BadRequest());
expect(badRequest.isBoom).to.be(true);
expect(badRequest.output.statusCode).to.be(400);
});
it('should transform elasticsearch errors into boom errors with the same status code', function () {
const conflict = handleESError(new esErrors.Conflict());
expect(conflict.isBoom).to.be(true);
expect(conflict.output.statusCode).to.be(409);
const forbidden = handleESError(new esErrors[403]);
expect(forbidden.isBoom).to.be(true);
expect(forbidden.output.statusCode).to.be(403);
const notFound = handleESError(new esErrors.NotFound());
expect(notFound.isBoom).to.be(true);
expect(notFound.output.statusCode).to.be(404);
const badRequest = handleESError(new esErrors.BadRequest());
expect(badRequest.isBoom).to.be(true);
expect(badRequest.output.statusCode).to.be(400);
});