mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
fix unit tests
This commit is contained in:
@@ -247,12 +247,12 @@ describe "ClsiManager", ->
|
|||||||
.calledWith(@project_id, {compiler:1, rootDoc_id: 1, imageName: 1, rootFolder: 1})
|
.calledWith(@project_id, {compiler:1, rootDoc_id: 1, imageName: 1, rootFolder: 1})
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should flush the project to the database", ->
|
it "should not explicitly flush the project to the database", ->
|
||||||
@DocumentUpdaterHandler.flushProjectToMongo
|
@DocumentUpdaterHandler.flushProjectToMongo
|
||||||
.calledWith(@project_id)
|
.calledWith(@project_id)
|
||||||
.should.equal true
|
.should.equal false
|
||||||
|
|
||||||
it "should get only the live docs from the docupdater", ->
|
it "should get only the live docs from the docupdater with a background flush in docupdater", ->
|
||||||
@DocumentUpdaterHandler.getProjectDocsIfMatch
|
@DocumentUpdaterHandler.getProjectDocsIfMatch
|
||||||
.calledWith(@project_id)
|
.calledWith(@project_id)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|||||||
+7
-7
@@ -265,19 +265,19 @@ describe 'DocumentUpdaterHandler', ->
|
|||||||
v: @version
|
v: @version
|
||||||
@docs = [ @doc0, @doc0, @doc0 ]
|
@docs = [ @doc0, @doc0, @doc0 ]
|
||||||
@body = JSON.stringify @docs
|
@body = JSON.stringify @docs
|
||||||
@request.get = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body)
|
@request.post = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body)
|
||||||
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
||||||
|
|
||||||
it 'should get the documenst from the document updater', ->
|
it 'should get the documenst from the document updater', ->
|
||||||
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}/doc?state=#{@project_state_hash}"
|
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}/get_and_flush_if_old?state=#{@project_state_hash}"
|
||||||
@request.get.calledWith(url).should.equal true
|
@request.post.calledWith(url).should.equal true
|
||||||
|
|
||||||
it "should call the callback with the documents", ->
|
it "should call the callback with the documents", ->
|
||||||
@callback.calledWithExactly(null, @docs).should.equal true
|
@callback.calledWithExactly(null, @docs).should.equal true
|
||||||
|
|
||||||
describe "when the document updater API returns an error", ->
|
describe "when the document updater API returns an error", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@request.get = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
|
@request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
|
||||||
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
||||||
|
|
||||||
it "should return an error to the callback", ->
|
it "should return an error to the callback", ->
|
||||||
@@ -285,7 +285,7 @@ describe 'DocumentUpdaterHandler', ->
|
|||||||
|
|
||||||
describe "when the document updater returns a conflict error code", ->
|
describe "when the document updater returns a conflict error code", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@request.get = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
|
@request.post = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
|
||||||
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
||||||
|
|
||||||
it "should return the callback with no documents", ->
|
it "should return the callback with no documents", ->
|
||||||
@@ -312,7 +312,7 @@ describe 'DocumentUpdaterHandler', ->
|
|||||||
|
|
||||||
describe "when the document updater API returns an error", ->
|
describe "when the document updater API returns an error", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@request.get = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
|
@request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
|
||||||
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
||||||
|
|
||||||
it "should return an error to the callback", ->
|
it "should return an error to the callback", ->
|
||||||
@@ -320,7 +320,7 @@ describe 'DocumentUpdaterHandler', ->
|
|||||||
|
|
||||||
describe "when the document updater returns a conflict error code", ->
|
describe "when the document updater returns a conflict error code", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@request.get = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
|
@request.post = sinon.stub().callsArgWith(1, null, { statusCode: 409 }, "Conflict")
|
||||||
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
@handler.getProjectDocsIfMatch @project_id, @project_state_hash, @callback
|
||||||
|
|
||||||
it "should return the callback with no documents", ->
|
it "should return the callback with no documents", ->
|
||||||
|
|||||||
Reference in New Issue
Block a user