mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 16:19:02 +02:00
[web+document-updater] Allow appending to documents (#20745)
Co-authored-by: David Powell <david.powell@overleaf.com> GitOrigin-RevId: f66283926e7da3edf83ada9316c3a001287e1b42
This commit is contained in:
committed by
Copybot
parent
b3e6111abc
commit
0b7fb0b622
@@ -14,6 +14,7 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const OError = require('@overleaf/o-error')
|
||||
|
||||
const modulePath = require('path').join(
|
||||
__dirname,
|
||||
@@ -1026,4 +1027,56 @@ describe('EditorController', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('appendToDoc', function () {
|
||||
describe('on success', function () {
|
||||
beforeEach(function () {
|
||||
this.docId = 'doc-1'
|
||||
this.ProjectEntityUpdateHandler.appendToDoc = sinon
|
||||
.stub()
|
||||
.yields(null, { rev: '1' })
|
||||
this.EditorController.appendToDoc(
|
||||
this.project_id,
|
||||
this.docId,
|
||||
this.docLines,
|
||||
this.source,
|
||||
this.user_id,
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('appends to the doc using the project entity handler', function () {
|
||||
this.ProjectEntityUpdateHandler.appendToDoc
|
||||
.calledWith(this.project_id, this.docId, this.docLines, this.source)
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('on error', function () {
|
||||
beforeEach(function () {
|
||||
this.docId = 'doc-1'
|
||||
this.ProjectEntityUpdateHandler.appendToDoc = sinon
|
||||
.stub()
|
||||
.yields(new Error('foo'))
|
||||
this.EditorController.appendToDoc(
|
||||
this.project_id,
|
||||
this.docId,
|
||||
this.docLines,
|
||||
this.source,
|
||||
this.user_id,
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('tries to append to the doc using the project entity handler', function () {
|
||||
this.ProjectEntityUpdateHandler.appendToDoc
|
||||
.calledWith(this.project_id, this.docId, this.docLines, this.source)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('tags the error', function () {
|
||||
this.callback.calledWith(sinon.match.instanceOf(OError))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user