overleaf/services/real-time/test/acceptance/js/SessionTests.js
Jakob Ackermann 7f9fd00bda Merge pull request #5367 from overleaf/jpa-node-handle-callback-err
[misc] fix eslint violations for node/handle-callback-err

GitOrigin-RevId: 83a4900e8861010df1917bff49382bd9c93375bd
2021-10-28 08:03:26 +00:00

60 lines
1.7 KiB
JavaScript

/* eslint-disable
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const { expect } = require('chai')
const RealTimeClient = require('./helpers/RealTimeClient')
describe('Session', function () {
return describe('with an established session', function () {
before(function (done) {
this.user_id = 'mock-user-id'
RealTimeClient.setSession(
{
user: { _id: this.user_id },
},
error => {
if (error != null) {
throw error
}
this.client = RealTimeClient.connect()
return done()
}
)
return null
})
it('should not get disconnected', function (done) {
let disconnected = false
this.client.on('disconnect', () => (disconnected = true))
return setTimeout(() => {
expect(disconnected).to.equal(false)
return done()
}, 500)
})
return it('should appear in the list of connected clients', function (done) {
return RealTimeClient.getConnectedClients((error, clients) => {
if (error) return done(error)
let included = false
for (const client of Array.from(clients)) {
if (client.client_id === this.client.socket.sessionid) {
included = true
break
}
}
expect(included).to.equal(true)
return done()
})
})
})
})