mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Fix joinDoc tests not passing options arg and restructure tests
This commit is contained in:
parent
ed252db25e
commit
b8d3f34e54
1 changed files with 24 additions and 14 deletions
|
@ -221,25 +221,25 @@ describe 'WebsocketController', ->
|
||||||
@version = 42
|
@version = 42
|
||||||
@ops = ["mock", "ops"]
|
@ops = ["mock", "ops"]
|
||||||
@ranges = { "mock": "ranges" }
|
@ranges = { "mock": "ranges" }
|
||||||
|
@options = {}
|
||||||
|
|
||||||
@client.params.project_id = @project_id
|
@client.params.project_id = @project_id
|
||||||
@AuthorizationManager.addAccessToDoc = sinon.stub()
|
@AuthorizationManager.addAccessToDoc = sinon.stub()
|
||||||
@AuthorizationManager.assertClientCanViewProject = sinon.stub().callsArgWith(1, null)
|
@AuthorizationManager.assertClientCanViewProject = sinon.stub().callsArgWith(1, null)
|
||||||
@DocumentUpdaterManager.getDocument = sinon.stub().callsArgWith(3, null, @doc_lines, @version, @ranges, @ops)
|
@DocumentUpdaterManager.getDocument = sinon.stub().callsArgWith(3, null, @doc_lines, @version, @ranges, @ops)
|
||||||
|
|
||||||
describe "with a fromVersion", ->
|
describe "works", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@fromVersion = 40
|
@WebsocketController.joinDoc @client, @doc_id, -1, @options, @callback
|
||||||
@WebsocketController.joinDoc @client, @doc_id, @fromVersion, @callback
|
|
||||||
|
|
||||||
it "should check that the client is authorized to view the project", ->
|
it "should check that the client is authorized to view the project", ->
|
||||||
@AuthorizationManager.assertClientCanViewProject
|
@AuthorizationManager.assertClientCanViewProject
|
||||||
.calledWith(@client)
|
.calledWith(@client)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should get the document from the DocumentUpdaterManager", ->
|
it "should get the document from the DocumentUpdaterManager with fromVersion", ->
|
||||||
@DocumentUpdaterManager.getDocument
|
@DocumentUpdaterManager.getDocument
|
||||||
.calledWith(@project_id, @doc_id, @fromVersion)
|
.calledWith(@project_id, @doc_id, -1)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should add permissions for the client to access the doc", ->
|
it "should add permissions for the client to access the doc", ->
|
||||||
|
@ -260,10 +260,20 @@ describe 'WebsocketController', ->
|
||||||
it "should increment the join-doc metric", ->
|
it "should increment the join-doc metric", ->
|
||||||
@metrics.inc.calledWith("editor.join-doc").should.equal true
|
@metrics.inc.calledWith("editor.join-doc").should.equal true
|
||||||
|
|
||||||
|
describe "with a fromVersion", ->
|
||||||
|
beforeEach ->
|
||||||
|
@fromVersion = 40
|
||||||
|
@WebsocketController.joinDoc @client, @doc_id, @fromVersion, @options, @callback
|
||||||
|
|
||||||
|
it "should get the document from the DocumentUpdaterManager with fromVersion", ->
|
||||||
|
@DocumentUpdaterManager.getDocument
|
||||||
|
.calledWith(@project_id, @doc_id, @fromVersion)
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
describe "with doclines that need escaping", ->
|
describe "with doclines that need escaping", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@doc_lines.push ["räksmörgås"]
|
@doc_lines.push ["räksmörgås"]
|
||||||
@WebsocketController.joinDoc @client, @doc_id, -1, @callback
|
@WebsocketController.joinDoc @client, @doc_id, -1, @options, @callback
|
||||||
|
|
||||||
it "should call the callback with the escaped lines", ->
|
it "should call the callback with the escaped lines", ->
|
||||||
escaped_lines = @callback.args[0][1]
|
escaped_lines = @callback.args[0][1]
|
||||||
|
@ -275,7 +285,7 @@ describe 'WebsocketController', ->
|
||||||
describe "when not authorized", ->
|
describe "when not authorized", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@AuthorizationManager.assertClientCanViewProject = sinon.stub().callsArgWith(1, @err = new Error("not authorized"))
|
@AuthorizationManager.assertClientCanViewProject = sinon.stub().callsArgWith(1, @err = new Error("not authorized"))
|
||||||
@WebsocketController.joinDoc @client, @doc_id, -1, @callback
|
@WebsocketController.joinDoc @client, @doc_id, -1, @options, @callback
|
||||||
|
|
||||||
it "should call the callback with an error", ->
|
it "should call the callback with an error", ->
|
||||||
@callback.calledWith(@err).should.equal true
|
@callback.calledWith(@err).should.equal true
|
||||||
|
|
Loading…
Reference in a new issue