mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add unit tests
This commit is contained in:
parent
19dfe5fc8b
commit
c2828c8ca5
3 changed files with 44 additions and 0 deletions
|
@ -32,6 +32,7 @@ describe "EditorController", ->
|
||||||
'../Project/ProjectEntityUpdateHandler' : @ProjectEntityUpdateHandler = {}
|
'../Project/ProjectEntityUpdateHandler' : @ProjectEntityUpdateHandler = {}
|
||||||
'../Project/ProjectOptionsHandler' : @ProjectOptionsHandler =
|
'../Project/ProjectOptionsHandler' : @ProjectOptionsHandler =
|
||||||
setCompiler: sinon.stub().yields()
|
setCompiler: sinon.stub().yields()
|
||||||
|
setImageName: sinon.stub().yields()
|
||||||
setSpellCheckLanguage: sinon.stub().yields()
|
setSpellCheckLanguage: sinon.stub().yields()
|
||||||
'../Project/ProjectDetailsHandler': @ProjectDetailsHandler =
|
'../Project/ProjectDetailsHandler': @ProjectDetailsHandler =
|
||||||
setProjectDescription: sinon.stub().yields()
|
setProjectDescription: sinon.stub().yields()
|
||||||
|
@ -377,6 +378,19 @@ describe "EditorController", ->
|
||||||
.calledWith(@project_id, "compilerUpdated", @compiler)
|
.calledWith(@project_id, "compilerUpdated", @compiler)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
|
describe "setImageName", ->
|
||||||
|
beforeEach ->
|
||||||
|
@imageName = "texlive-1234.5"
|
||||||
|
@EditorController.setImageName @project_id, @imageName, @callback
|
||||||
|
|
||||||
|
it "should send the new imageName and project id to the project options handler", ->
|
||||||
|
@ProjectOptionsHandler.setImageName
|
||||||
|
.calledWith(@project_id, @imageName)
|
||||||
|
.should.equal true
|
||||||
|
@EditorRealTimeController.emitToRoom
|
||||||
|
.calledWith(@project_id, "imageNameUpdated", @imageName)
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
describe "setSpellCheckLanguage", ->
|
describe "setSpellCheckLanguage", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@languageCode = "fr"
|
@languageCode = "fr"
|
||||||
|
|
|
@ -145,6 +145,18 @@ describe "ProjectController", ->
|
||||||
done()
|
done()
|
||||||
@ProjectController.updateProjectSettings @req, @res
|
@ProjectController.updateProjectSettings @req, @res
|
||||||
|
|
||||||
|
it "should update the imageName", (done) ->
|
||||||
|
@EditorController.setImageName = sinon.stub().callsArg(2)
|
||||||
|
@req.body =
|
||||||
|
imageName: @imageName = "texlive-1234.5"
|
||||||
|
@res.sendStatus = (code) =>
|
||||||
|
@EditorController.setImageName
|
||||||
|
.calledWith(@project_id, @imageName)
|
||||||
|
.should.equal true
|
||||||
|
code.should.equal 204
|
||||||
|
done()
|
||||||
|
@ProjectController.updateProjectSettings @req, @res
|
||||||
|
|
||||||
it "should update the spell check language", (done) ->
|
it "should update the spell check language", (done) ->
|
||||||
@EditorController.setSpellCheckLanguage = sinon.stub().callsArg(2)
|
@EditorController.setSpellCheckLanguage = sinon.stub().callsArg(2)
|
||||||
@req.body =
|
@req.body =
|
||||||
|
|
|
@ -19,6 +19,11 @@ describe 'creating a project', ->
|
||||||
{name: "English", code: "en"}
|
{name: "English", code: "en"}
|
||||||
{name: "French", code: "fr"}
|
{name: "French", code: "fr"}
|
||||||
]
|
]
|
||||||
|
imageRoot: "docker-repo/subdir"
|
||||||
|
allowedImageNames: [
|
||||||
|
{imageName: "texlive-0000.0", imageDesc: "test image 0"}
|
||||||
|
{imageName: "texlive-1234.5", imageDesc: "test image 1"}
|
||||||
|
]
|
||||||
'logger-sharelatex':
|
'logger-sharelatex':
|
||||||
log:->
|
log:->
|
||||||
err:->
|
err:->
|
||||||
|
@ -37,6 +42,19 @@ describe 'creating a project', ->
|
||||||
@projectModel.update.called.should.equal false
|
@projectModel.update.called.should.equal false
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
describe 'Setting the imageName', ->
|
||||||
|
it 'should perform and update on mongo', (done)->
|
||||||
|
@handler.setImageName project_id, "texlive-1234.5", (err)=>
|
||||||
|
args = @projectModel.update.args[0]
|
||||||
|
args[0]._id.should.equal project_id
|
||||||
|
args[1].imageName.should.equal "docker-repo/subdir/texlive-1234.5"
|
||||||
|
done()
|
||||||
|
@projectModel.update.args[0][3]()
|
||||||
|
|
||||||
|
it 'should not perform and update on mongo if it is not a reconised compiler', (done)->
|
||||||
|
@handler.setImageName project_id, "something", (err)=>
|
||||||
|
@projectModel.update.called.should.equal false
|
||||||
|
done()
|
||||||
|
|
||||||
describe "setting the spellCheckLanguage", ->
|
describe "setting the spellCheckLanguage", ->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue