mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 01:04:30 -05:00
2c9b222437
because a promise is returned from ioredis it errors in mocha as it can't take a promise and a callback
35 lines
903 B
CoffeeScript
35 lines
903 B
CoffeeScript
chai = require("chai")
|
|
expect = chai.expect
|
|
|
|
RealTimeClient = require "./helpers/RealTimeClient"
|
|
|
|
describe "Session", ->
|
|
describe "with an established session", ->
|
|
before (done) ->
|
|
@user_id = "mock-user-id"
|
|
RealTimeClient.setSession {
|
|
user: { _id: @user_id }
|
|
}, (error) =>
|
|
throw error if error?
|
|
@client = RealTimeClient.connect()
|
|
return done()
|
|
return null
|
|
|
|
it "should not get disconnected", (done) ->
|
|
disconnected = false
|
|
@client.on "disconnect", () ->
|
|
disconnected = true
|
|
setTimeout () =>
|
|
expect(disconnected).to.equal false
|
|
done()
|
|
, 500
|
|
|
|
it "should appear in the list of connected clients", (done) ->
|
|
RealTimeClient.getConnectedClients (error, clients) =>
|
|
included = false
|
|
for client in clients
|
|
if client.client_id == @client.socket.sessionid
|
|
included = true
|
|
break
|
|
expect(included).to.equal true
|
|
done()
|