mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
added test for inserting as pack
This commit is contained in:
@@ -51,12 +51,11 @@ describe "UpdatesManager", ->
|
||||
.calledWith(@doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should save the compressed ops", ->
|
||||
it "should save the compressed ops as a pack", ->
|
||||
@PackManager.insertCompressedUpdates
|
||||
.calledWith(@project_id, @doc_id, null, @compressedUpdates, @temporary)
|
||||
.should.equal true
|
||||
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
@@ -98,6 +97,30 @@ describe "UpdatesManager", ->
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
describe "when the raw ops start where the existing history ends and the history is in a pack", ->
|
||||
beforeEach ->
|
||||
@lastCompressedUpdate = {pack: [{ v: 11, op: "compressed-op-11" }], v:11}
|
||||
@rawUpdates = [{ v: 12, op: "mock-op-12" }, { v: 13, op: "mock-op-13" }]
|
||||
@MongoManager.peekLastCompressedUpdate = sinon.stub().callsArgWith(1, null, @lastCompressedUpdate, @lastCompressedUpdate.v)
|
||||
@UpdatesManager.compressAndSaveRawUpdates @project_id, @doc_id, @rawUpdates, @temporary, @callback
|
||||
|
||||
it "should look at the last compressed op", ->
|
||||
@MongoManager.peekLastCompressedUpdate
|
||||
.calledWith(@doc_id)
|
||||
.should.equal true
|
||||
|
||||
it "should defer the compression of raw ops to PackManager", ->
|
||||
@UpdateCompressor.compressRawUpdates
|
||||
.should.not.be.called
|
||||
|
||||
it "should save the new compressed ops into a pack", ->
|
||||
@PackManager.insertCompressedUpdates
|
||||
.calledWith(@project_id, @doc_id, @lastCompressedUpdate, @compressedUpdates, @temporary)
|
||||
.should.equal true
|
||||
|
||||
it "should call the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
describe "when some raw ops are passed that have already been compressed", ->
|
||||
beforeEach ->
|
||||
@rawUpdates = [{ v: 10, op: "mock-op-10" }, { v: 11, op: "mock-op-11"}, { v: 12, op: "mock-op-12" }, { v: 13, op: "mock-op-13" }]
|
||||
|
||||
Reference in New Issue
Block a user