2020-06-23 13:30:34 -04:00
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2020-06-23 13:30:29 -04:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2020-06-23 13:30:45 -04:00
|
|
|
const async = require('async')
|
|
|
|
const { expect } = require('chai')
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
const RealTimeClient = require('./helpers/RealTimeClient')
|
|
|
|
const FixturesManager = require('./helpers/FixturesManager')
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
describe('Router', function () {
|
|
|
|
return describe('joinProject', function () {
|
|
|
|
describe('when there is no callback provided', function () {
|
|
|
|
after(function () {
|
|
|
|
return process.removeListener('unhandledRejection', this.onUnhandled)
|
|
|
|
})
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
before(function (done) {
|
2021-07-13 07:04:45 -04:00
|
|
|
this.onUnhandled = error => done(error)
|
2020-06-23 13:30:45 -04:00
|
|
|
process.on('unhandledRejection', this.onUnhandled)
|
|
|
|
return async.series(
|
|
|
|
[
|
2021-07-13 07:04:45 -04:00
|
|
|
cb => {
|
2020-06-23 13:30:45 -04:00
|
|
|
return FixturesManager.setUpProject(
|
|
|
|
{
|
|
|
|
privilegeLevel: 'owner',
|
|
|
|
project: {
|
2021-07-13 07:04:45 -04:00
|
|
|
name: 'Test Project',
|
|
|
|
},
|
2020-06-23 13:30:29 -04:00
|
|
|
},
|
2023-03-20 10:10:40 -04:00
|
|
|
(e, { project_id: projectId, user_id: userId }) => {
|
|
|
|
this.project_id = projectId
|
|
|
|
this.user_id = userId
|
2020-06-23 13:30:45 -04:00
|
|
|
return cb(e)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2021-07-13 07:04:45 -04:00
|
|
|
cb => {
|
2023-11-29 09:50:21 -05:00
|
|
|
this.client = RealTimeClient.connect(this.project_id, cb)
|
2020-06-23 13:30:45 -04:00
|
|
|
},
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2021-07-13 07:04:45 -04:00
|
|
|
cb => {
|
2020-06-23 13:30:45 -04:00
|
|
|
return setTimeout(cb, 100)
|
2021-07-13 07:04:45 -04:00
|
|
|
},
|
2020-06-23 13:30:45 -04:00
|
|
|
],
|
|
|
|
done
|
|
|
|
)
|
|
|
|
})
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
return it('should keep on going', function () {
|
|
|
|
return expect('still running').to.exist
|
|
|
|
})
|
|
|
|
})
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
return describe('when there are too many arguments', function () {
|
|
|
|
after(function () {
|
|
|
|
return process.removeListener('unhandledRejection', this.onUnhandled)
|
|
|
|
})
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
before(function (done) {
|
2021-07-13 07:04:45 -04:00
|
|
|
this.onUnhandled = error => done(error)
|
2020-06-23 13:30:45 -04:00
|
|
|
process.on('unhandledRejection', this.onUnhandled)
|
|
|
|
return async.series(
|
|
|
|
[
|
2021-07-13 07:04:45 -04:00
|
|
|
cb => {
|
2020-06-23 13:30:45 -04:00
|
|
|
return FixturesManager.setUpProject(
|
|
|
|
{
|
|
|
|
privilegeLevel: 'owner',
|
|
|
|
project: {
|
2021-07-13 07:04:45 -04:00
|
|
|
name: 'Test Project',
|
|
|
|
},
|
2020-06-23 13:30:29 -04:00
|
|
|
},
|
2023-03-20 10:10:40 -04:00
|
|
|
(e, { project_id: projectId, user_id: userId }) => {
|
|
|
|
this.project_id = projectId
|
|
|
|
this.user_id = userId
|
2020-06-23 13:30:45 -04:00
|
|
|
return cb(e)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2021-07-13 07:04:45 -04:00
|
|
|
cb => {
|
2023-11-29 09:50:21 -05:00
|
|
|
this.client = RealTimeClient.connect(this.project_id, cb)
|
2020-06-23 13:30:45 -04:00
|
|
|
},
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2021-07-13 07:04:45 -04:00
|
|
|
cb => {
|
2023-11-29 09:50:21 -05:00
|
|
|
return this.client.emit('joinDoc', 1, 2, 3, 4, 5, error => {
|
2020-06-23 13:30:45 -04:00
|
|
|
this.error = error
|
|
|
|
return cb()
|
|
|
|
})
|
2021-07-13 07:04:45 -04:00
|
|
|
},
|
2020-06-23 13:30:45 -04:00
|
|
|
],
|
|
|
|
done
|
|
|
|
)
|
|
|
|
})
|
2020-06-09 11:30:03 -04:00
|
|
|
|
2020-06-23 13:30:45 -04:00
|
|
|
return it('should return an error message', function () {
|
|
|
|
return expect(this.error.message).to.equal('unexpected arguments')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|