SessionTests.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* eslint-disable
  2. no-return-assign,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS101: Remove unnecessary use of Array.from
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * DS207: Consider shorter variations of null checks
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. import { expect } from 'chai'
  14. import FixturesManager from './helpers/FixturesManager.js'
  15. import RealTimeClient from './helpers/RealTimeClient.js'
  16. describe('Session', function () {
  17. return describe('with an established session', function () {
  18. before(function (done) {
  19. FixturesManager.setUpProject(
  20. { privilegeLevel: 'owner' },
  21. (error, options) => {
  22. if (error) return done(error)
  23. this.client = RealTimeClient.connect(options.project_id, done)
  24. }
  25. )
  26. return null
  27. })
  28. it('should not get disconnected', function (done) {
  29. let disconnected = false
  30. this.client.on('disconnect', () => (disconnected = true))
  31. return setTimeout(() => {
  32. expect(disconnected).to.equal(false)
  33. return done()
  34. }, 500)
  35. })
  36. return it('should appear in the list of connected clients', function (done) {
  37. return RealTimeClient.getConnectedClients((error, clients) => {
  38. if (error) return done(error)
  39. let included = false
  40. for (const client of Array.from(clients)) {
  41. if (client.client_id === this.client.socket.sessionid) {
  42. included = true
  43. break
  44. }
  45. }
  46. expect(included).to.equal(true)
  47. return done()
  48. })
  49. })
  50. })
  51. })