mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
ffd10a8439
The version number is only used by the doc updater and so can be cleanly encapsulated in a collection that only the doc updater knows about. The version is already stored under docOps, so continue to tore it there.
38 lines
1.2 KiB
CoffeeScript
38 lines
1.2 KiB
CoffeeScript
sinon = require('sinon')
|
|
chai = require('chai')
|
|
should = chai.should()
|
|
modulePath = "../../../../app/js/PersistenceManager.js"
|
|
SandboxedModule = require('sandboxed-module')
|
|
|
|
describe "PersistenceManager.setDoc", ->
|
|
beforeEach ->
|
|
@PersistenceManager = SandboxedModule.require modulePath, requires:
|
|
"request": @request = sinon.stub()
|
|
"settings-sharelatex": @Settings = {}
|
|
"./Metrics": @Metrics =
|
|
Timer: class Timer
|
|
done: sinon.stub()
|
|
"logger-sharelatex": @logger = {warn: sinon.stub()}
|
|
|
|
@project_id = "mock-project-id"
|
|
@doc_id = "mock-doc-id"
|
|
@callback = sinon.stub()
|
|
@lines = ["mock", "doc", "lines"]
|
|
|
|
@PersistenceManager.setDocInWeb = sinon.stub().callsArg(3)
|
|
@PersistenceManager.setDocVersionInMongo = sinon.stub().callsArg(2)
|
|
|
|
@PersistenceManager.setDoc @project_id, @doc_id, @lines, @version, @callback
|
|
|
|
it "should set the doc in the web api", ->
|
|
@PersistenceManager.setDocInWeb
|
|
.calledWith(@project_id, @doc_id, @lines)
|
|
.should.equal true
|
|
|
|
it "should set the doc version in mongo", ->
|
|
@PersistenceManager.setDocVersionInMongo
|
|
.calledWith(@doc_id, @version)
|
|
.should.equal true
|
|
|
|
it "should call the callback", ->
|
|
@callback.called.should.equal true
|