Merge pull request #2988 from overleaf/msm-oerror-remove-not-found-error

Replace HTTPErrors.NotFoundError with calls to notFound() handler

GitOrigin-RevId: c98582a5bd3d862b3c17fb03d863c75f64851aba
This commit is contained in:
Miguel Serrano
2020-07-16 16:55:05 +02:00
committed by Copybot
parent 63503f2079
commit 244709df5e
7 changed files with 92 additions and 42 deletions

View File

@@ -123,6 +123,7 @@ describe('EditorHttpController', function() {
}
}
this.HttpErrorHandler = {
notFound: sinon.stub(),
unprocessableEntity: sinon.stub()
}
this.EditorHttpController = SandboxedModule.require(MODULE_PATH, {
@@ -559,5 +560,20 @@ describe('EditorHttpController', function() {
this.EditorHttpController.convertDocToFile(this.req, this.res)
})
})
describe("when the doc does't exist", function() {
it('should return a 404 - not found', function(done) {
this.ProjectEntityUpdateHandler.promises.convertDocToFile.rejects(
new Errors.NotFoundError({})
)
this.HttpErrorHandler.notFound = sinon.spy((req, res, message) => {
expect(req).to.exist
expect(res).to.exist
expect(message).to.equal('Document not found')
done()
})
this.EditorHttpController.convertDocToFile(this.req, this.res)
})
})
})
})