mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
fix unit test
This commit is contained in:
@@ -78,15 +78,31 @@ describe "DocArchiveManager", ->
|
||||
describe "unArchiveAllDocsChanges", ->
|
||||
it "should unarchive all project docs change", (done)->
|
||||
@DocstoreHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @mongoDocs)
|
||||
@DocArchiveManager.unArchiveDocChanges = sinon.stub().callsArgWith(2, null)
|
||||
@DocArchiveManager.unArchiveDocChangesWithLock = sinon.stub().callsArgWith(2, null)
|
||||
|
||||
@DocArchiveManager.unArchiveAllDocsChanges @project_id, (err)=>
|
||||
@DocArchiveManager.unArchiveDocChanges.calledWith(@project_id, @mongoDocs[0]._id).should.equal true
|
||||
@DocArchiveManager.unArchiveDocChanges.calledWith(@project_id, @mongoDocs[1]._id).should.equal true
|
||||
@DocArchiveManager.unArchiveDocChanges.calledWith(@project_id, @mongoDocs[2]._id).should.equal true
|
||||
@DocArchiveManager.unArchiveDocChangesWithLock.calledWith(@project_id, @mongoDocs[0]._id).should.equal true
|
||||
@DocArchiveManager.unArchiveDocChangesWithLock.calledWith(@project_id, @mongoDocs[1]._id).should.equal true
|
||||
@DocArchiveManager.unArchiveDocChangesWithLock.calledWith(@project_id, @mongoDocs[2]._id).should.equal true
|
||||
should.not.exist err
|
||||
done()
|
||||
|
||||
describe "unArchiveDocChangesWithLock", ->
|
||||
beforeEach ->
|
||||
@DocArchiveManager.unArchiveDocChanges = sinon.stub().callsArg(2)
|
||||
@LockManager.runWithLock = sinon.stub().callsArg(2)
|
||||
@DocArchiveManager.unArchiveDocChangesWithLock @project_id, @doc_id, @callback
|
||||
|
||||
it "should run unArchiveDocChangesWithLock with the lock", ->
|
||||
@LockManager.runWithLock
|
||||
.calledWith(
|
||||
"HistoryLock:#{@doc_id}"
|
||||
)
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
describe "unArchiveDocChanges", ->
|
||||
beforeEach ->
|
||||
@MongoManager.getArchivedDocChanges = sinon.stub().callsArg(1)
|
||||
|
||||
@@ -37,19 +37,20 @@ describe "MongoAWS", ->
|
||||
@awssdk.S3 = sinon.stub()
|
||||
@s3streams.WriteStream = sinon.stub()
|
||||
@db.docHistory = {}
|
||||
@db.docHistory.pipe = sinon.stub()
|
||||
@db.docHistory.on = sinon.stub()
|
||||
@db.docHistory.find = sinon.stub().returns @db.docHistory
|
||||
@db.docHistory.pipe.returns
|
||||
@db.docHistory.on.returns
|
||||
pipe:->
|
||||
on: (type, cb)->
|
||||
if type == "finish"
|
||||
cb()
|
||||
pipe:->
|
||||
on: (type, cb)->
|
||||
on: (type, cb)->
|
||||
cb()
|
||||
@JSONStream.stringify = sinon.stub()
|
||||
|
||||
@MongoAWS.archiveDocHistory @project_id, @doc_id, @callback
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.calledWith(null).should.equal true
|
||||
@callback.called.should.equal true
|
||||
|
||||
describe "unArchiveDocHistory", ->
|
||||
|
||||
@@ -61,21 +62,23 @@ describe "MongoAWS", ->
|
||||
@s3streams.ReadStream.returns
|
||||
#describe on 'open' behavior
|
||||
on: (type, cb)->
|
||||
pipe:->
|
||||
#describe on 'data' behavior
|
||||
on: (type, cb)->
|
||||
cb([])
|
||||
#describe on 'end' behavior
|
||||
on: (type, cb)->
|
||||
cb()
|
||||
#describe on 'error' behavior
|
||||
on: sinon.stub()
|
||||
#describe on 'error' behavior
|
||||
on: (type, cb)->
|
||||
pipe:->
|
||||
#describe on 'data' behavior
|
||||
on: (type, cb)->
|
||||
cb([])
|
||||
#describe on 'end' behavior
|
||||
on: (type, cb)->
|
||||
cb()
|
||||
#describe on 'error' behavior
|
||||
on: sinon.stub()
|
||||
|
||||
@MongoAWS.handleBulk = sinon.stub()
|
||||
@MongoAWS.unArchiveDocHistory @project_id, @doc_id, @callback
|
||||
|
||||
it "should call handleBulk", ->
|
||||
@MongoAWS.handleBulk.calledWith([],@callback).should.equal true
|
||||
@MongoAWS.handleBulk.called.should.equal true
|
||||
|
||||
describe "handleBulk", ->
|
||||
beforeEach ->
|
||||
|
||||
Reference in New Issue
Block a user