mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-30 10:42:42 +00:00
Add acceptance tests for joinDoc variadic
This commit is contained in:
parent
785d6e2eea
commit
6470577c3f
1 changed files with 78 additions and 1 deletions
|
@ -166,4 +166,81 @@ describe "joinDoc", ->
|
|||
it "should have joined the doc room", (done) ->
|
||||
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||
expect(@doc_id in client.rooms).to.equal true
|
||||
done()
|
||||
done()
|
||||
|
||||
describe "with options", ->
|
||||
before (done) ->
|
||||
@options = { encodeRanges: true }
|
||||
async.series [
|
||||
(cb) =>
|
||||
FixturesManager.setUpProject {
|
||||
privilegeLevel: "readAndWrite"
|
||||
}, (e, {@project_id, @user_id}) =>
|
||||
cb(e)
|
||||
|
||||
(cb) =>
|
||||
FixturesManager.setUpDoc @project_id, {@lines, @version, @ops, @ranges}, (e, {@doc_id}) =>
|
||||
cb(e)
|
||||
|
||||
(cb) =>
|
||||
@client = RealTimeClient.connect()
|
||||
@client.on "connectionAccepted", cb
|
||||
|
||||
(cb) =>
|
||||
@client.emit "joinProject", project_id: @project_id, cb
|
||||
|
||||
(cb) =>
|
||||
@client.emit "joinDoc", @doc_id, @options, (error, @returnedArgs...) => cb(error)
|
||||
], done
|
||||
|
||||
it "should get the doc from the doc updater with the default fromVersion", ->
|
||||
MockDocUpdaterServer.getDocument
|
||||
.calledWith(@project_id, @doc_id, -1)
|
||||
.should.equal true
|
||||
|
||||
it "should return the doc lines, version, ranges and ops", ->
|
||||
@returnedArgs.should.deep.equal [@lines, @version, @ops, @ranges]
|
||||
|
||||
it "should have joined the doc room", (done) ->
|
||||
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||
expect(@doc_id in client.rooms).to.equal true
|
||||
done()
|
||||
|
||||
describe "with fromVersion and options", ->
|
||||
before (done) ->
|
||||
@fromVersion = 36
|
||||
@options = { encodeRanges: true }
|
||||
async.series [
|
||||
(cb) =>
|
||||
FixturesManager.setUpProject {
|
||||
privilegeLevel: "readAndWrite"
|
||||
}, (e, {@project_id, @user_id}) =>
|
||||
cb(e)
|
||||
|
||||
(cb) =>
|
||||
FixturesManager.setUpDoc @project_id, {@lines, @version, @ops, @ranges}, (e, {@doc_id}) =>
|
||||
cb(e)
|
||||
|
||||
(cb) =>
|
||||
@client = RealTimeClient.connect()
|
||||
@client.on "connectionAccepted", cb
|
||||
|
||||
(cb) =>
|
||||
@client.emit "joinProject", project_id: @project_id, cb
|
||||
|
||||
(cb) =>
|
||||
@client.emit "joinDoc", @doc_id, @fromVersion, @options, (error, @returnedArgs...) => cb(error)
|
||||
], done
|
||||
|
||||
it "should get the doc from the doc updater with the fromVersion", ->
|
||||
MockDocUpdaterServer.getDocument
|
||||
.calledWith(@project_id, @doc_id, @fromVersion)
|
||||
.should.equal true
|
||||
|
||||
it "should return the doc lines, version, ranges and ops", ->
|
||||
@returnedArgs.should.deep.equal [@lines, @version, @ops, @ranges]
|
||||
|
||||
it "should have joined the doc room", (done) ->
|
||||
RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
|
||||
expect(@doc_id in client.rooms).to.equal true
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue