RouterTests.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Fix any style issues and re-enable lint.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  7. */
  8. import async from 'async'
  9. import { expect } from 'chai'
  10. import RealTimeClient from './helpers/RealTimeClient.js'
  11. import FixturesManager from './helpers/FixturesManager.js'
  12. describe('Router', function () {
  13. return describe('joinProject', function () {
  14. describe('when there is no callback provided', function () {
  15. after(function () {
  16. return process.removeListener('unhandledRejection', this.onUnhandled)
  17. })
  18. before(function (done) {
  19. this.onUnhandled = error => done(error)
  20. process.on('unhandledRejection', this.onUnhandled)
  21. return async.series(
  22. [
  23. cb => {
  24. return FixturesManager.setUpProject(
  25. {
  26. privilegeLevel: 'owner',
  27. project: {
  28. name: 'Test Project',
  29. },
  30. },
  31. (e, { project_id: projectId, user_id: userId }) => {
  32. this.project_id = projectId
  33. this.user_id = userId
  34. return cb(e)
  35. }
  36. )
  37. },
  38. cb => {
  39. this.client = RealTimeClient.connect(this.project_id, cb)
  40. },
  41. cb => {
  42. return setTimeout(cb, 100)
  43. },
  44. ],
  45. done
  46. )
  47. })
  48. return it('should keep on going', function () {
  49. return expect('still running').to.exist
  50. })
  51. })
  52. return describe('when there are too many arguments', function () {
  53. after(function () {
  54. return process.removeListener('unhandledRejection', this.onUnhandled)
  55. })
  56. before(function (done) {
  57. this.onUnhandled = error => done(error)
  58. process.on('unhandledRejection', this.onUnhandled)
  59. return async.series(
  60. [
  61. cb => {
  62. return FixturesManager.setUpProject(
  63. {
  64. privilegeLevel: 'owner',
  65. project: {
  66. name: 'Test Project',
  67. },
  68. },
  69. (e, { project_id: projectId, user_id: userId }) => {
  70. this.project_id = projectId
  71. this.user_id = userId
  72. return cb(e)
  73. }
  74. )
  75. },
  76. cb => {
  77. this.client = RealTimeClient.connect(this.project_id, cb)
  78. },
  79. cb => {
  80. return this.client.emit('joinDoc', 1, 2, 3, 4, 5, error => {
  81. this.error = error
  82. return cb()
  83. })
  84. },
  85. ],
  86. done
  87. )
  88. })
  89. return it('should return an error message', function () {
  90. return expect(this.error.message).to.equal('unexpected arguments')
  91. })
  92. })
  93. })
  94. })