mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-27 11:01:56 +02:00
Merge pull request #2985 from overleaf/msm-oerror-remove-unprocessable-entity-error
Replace UnprocessableEntityError with calls to unprocessableEntity() handler GitOrigin-RevId: 4bba389c8cdf87a40137d49db571fa81aaac4239
This commit is contained in:
@@ -45,4 +45,42 @@ describe('HttpErrorHandler', function() {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('unprocessableEntity', function() {
|
||||
it('returns 422', function() {
|
||||
this.HttpErrorHandler.unprocessableEntity(this.req, this.res)
|
||||
expect(this.res.statusCode).to.equal(422)
|
||||
})
|
||||
|
||||
it('should print a message when no content-type is included', function() {
|
||||
this.HttpErrorHandler.unprocessableEntity(this.req, this.res)
|
||||
expect(this.res.body).to.equal('unprocessable entity')
|
||||
})
|
||||
|
||||
it("should render a template including the error message when content-type is 'html'", function() {
|
||||
this.req.accepts = () => 'html'
|
||||
this.HttpErrorHandler.unprocessableEntity(this.req, this.res, 'an error')
|
||||
expect(this.res.renderedTemplate).to.equal('general/400')
|
||||
expect(this.res.renderedVariables).to.deep.equal({
|
||||
title: 'Client Error',
|
||||
message: 'an error'
|
||||
})
|
||||
})
|
||||
|
||||
it("should return a json object when content-type is 'json'", function() {
|
||||
this.req.accepts = () => 'json'
|
||||
this.HttpErrorHandler.unprocessableEntity(
|
||||
this.req,
|
||||
this.res,
|
||||
'an error',
|
||||
{
|
||||
foo: 'bar'
|
||||
}
|
||||
)
|
||||
expect(JSON.parse(this.res.body)).to.deep.equal({
|
||||
message: 'an error',
|
||||
foo: 'bar'
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user