overleaf/services/document-updater/test/unit/coffee/PersistenceManager/setDocTests.coffee
James Allen ffd10a8439 Don't send or get versioning info to/from web
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.
2014-05-15 11:13:16 +01:00

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