mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 03:12:12 +00:00
added test for inserting as pack
This commit is contained in:
parent
399a8f0a29
commit
61d22f027a
1 changed files with 25 additions and 2 deletions
|
@ -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" }]
|
||||
|
|
Loading…
Reference in a new issue