fix unit tests

This commit is contained in:
Brian Gough 2017-08-08 11:38:31 +01:00
parent 849e905efb
commit 31e71854a4
2 changed files with 11 additions and 4 deletions

View file

@ -182,7 +182,6 @@ module.exports = ClsiManager =
resources.push
path: path
content: doc.lines.join("\n")
rev: doc.rev
if project.rootDoc_id? and doc._id.toString() == project.rootDoc_id.toString()
rootResourcePath = path
if options.rootDoc_id? and doc._id.toString() == options.rootDoc_id.toString()

View file

@ -12,6 +12,8 @@ describe "ClsiManager", ->
getCookieJar: sinon.stub().callsArgWith(1, null, @jar)
setServerId: sinon.stub().callsArgWith(2)
_getServerId:sinon.stub()
@ClsiStateManager =
computeHash: sinon.stub().callsArgWith(1, null, "01234567890abcdef")
@ClsiFormatChecker =
checkRecoursesForProblems:sinon.stub().callsArgWith(1)
@ClsiManager = SandboxedModule.require modulePath, requires:
@ -26,8 +28,11 @@ describe "ClsiManager", ->
url: "https://clsipremium.example.com"
"../../models/Project": Project: @Project = {}
"../Project/ProjectEntityHandler": @ProjectEntityHandler = {}
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler = {}
"../Project/ProjectGetter": @ProjectGetter = {}
"../DocumentUpdater/DocumentUpdaterHandler": @DocumentUpdaterHandler =
getProjectDocsIfMatch: sinon.stub().callsArgWith(2,null,null)
"./ClsiCookieManager": @ClsiCookieManager
"./ClsiStateManager": @ClsiStateManager
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub(), warn: sinon.stub() }
"request": @request = sinon.stub()
"./ClsiFormatChecker": @ClsiFormatChecker
@ -145,6 +150,7 @@ describe "ClsiManager", ->
@Project.findById = sinon.stub().callsArgWith(2, null, @project)
@ProjectEntityHandler.getAllDocs = sinon.stub().callsArgWith(1, null, @docs)
@ProjectEntityHandler.getAllFiles = sinon.stub().callsArgWith(1, null, @files)
@ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, @project)
@DocumentUpdaterHandler.flushProjectToMongo = sinon.stub().callsArgWith(1, null)
describe "with a valid project", ->
@ -154,8 +160,8 @@ describe "ClsiManager", ->
done()
it "should get the project with the required fields", ->
@Project.findById
.calledWith(@project_id, {compiler:1, rootDoc_id: 1, imageName: 1})
@ProjectGetter.getProject
.calledWith(@project_id, {compiler:1, rootDoc_id: 1, imageName: 1, rootFolder: 1})
.should.equal true
it "should flush the project to the database", ->
@ -182,6 +188,8 @@ describe "ClsiManager", ->
imageName: @image
draft: false
check: undefined
syncType: "full"
syncState: "01234567890abcdef"
rootResourcePath: "main.tex"
resources: [{
path: "main.tex"