|
|
@@ -510,66 +510,4 @@ describe('EditorHttpController', function () {
|
|
|
expect(this.res.sendStatus).to.have.been.calledWith(204)
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- describe('convertDocToFile', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
- this.req.params = {
|
|
|
- Project_id: this.project._id.toString(),
|
|
|
- entity_id: this.doc._id.toString(),
|
|
|
- }
|
|
|
- this.req.body = { userId: this.user._id.toString() }
|
|
|
- this.res.json.callsFake(() => done())
|
|
|
- this.EditorHttpController.convertDocToFile(this.req, this.res)
|
|
|
- })
|
|
|
-
|
|
|
- describe('when successful', function () {
|
|
|
- it('should convert the doc to a file', function () {
|
|
|
- expect(
|
|
|
- this.ProjectEntityUpdateHandler.promises.convertDocToFile
|
|
|
- ).to.have.been.calledWith(
|
|
|
- this.project._id.toString(),
|
|
|
- this.doc._id.toString(),
|
|
|
- this.user._id.toString()
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- it('should return the file id in the response', function () {
|
|
|
- expect(this.res.json).to.have.been.calledWith({
|
|
|
- fileId: this.file._id.toString(),
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- describe('when the doc has ranges', function () {
|
|
|
- it('should return a 422 - Unprocessable Entity', function (done) {
|
|
|
- this.ProjectEntityUpdateHandler.promises.convertDocToFile.rejects(
|
|
|
- new Errors.DocHasRangesError({})
|
|
|
- )
|
|
|
- this.HttpErrorHandler.unprocessableEntity = sinon.spy(
|
|
|
- (req, res, message) => {
|
|
|
- expect(req).to.exist
|
|
|
- expect(res).to.exist
|
|
|
- expect(message).to.equal('Document has comments or tracked changes')
|
|
|
- done()
|
|
|
- }
|
|
|
- )
|
|
|
- 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)
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
})
|