mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 14:19:01 +02:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -23,8 +23,8 @@ const modulePath = Path.join(
|
||||
'../../../../app/src/Features/Project/ProjectCollabratecDetailsHandler'
|
||||
)
|
||||
|
||||
describe('ProjectCollabratecDetailsHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('ProjectCollabratecDetailsHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.projectId = ObjectId('5bea8747c7bba6012fcaceb3')
|
||||
this.userId = ObjectId('5be316a9c7f6aa03802ea8fb')
|
||||
this.userId2 = ObjectId('5c1794b3f0e89b1d1c577eca')
|
||||
@@ -41,9 +41,9 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
return (this.callback = sinon.stub())
|
||||
})
|
||||
|
||||
describe('initializeCollabratecProject', function() {
|
||||
describe('when update succeeds', function() {
|
||||
beforeEach(function() {
|
||||
describe('initializeCollabratecProject', function () {
|
||||
describe('when update succeeds', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields()
|
||||
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
|
||||
this.projectId,
|
||||
@@ -54,7 +54,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update project model', function() {
|
||||
it('should update project model', function () {
|
||||
const update = {
|
||||
$set: {
|
||||
collabratecUsers: [
|
||||
@@ -74,8 +74,8 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when update has error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when update has error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields('error')
|
||||
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
|
||||
this.projectId,
|
||||
@@ -86,13 +86,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback).to.have.been.calledWith('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid args', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid args', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
|
||||
'bad-project-id',
|
||||
@@ -103,24 +103,24 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('isLinkedCollabratecUserProject', function() {
|
||||
beforeEach(function() {
|
||||
describe('isLinkedCollabratecUserProject', function () {
|
||||
beforeEach(function () {
|
||||
return (this.ProjectModel.findOne = sinon.stub().yields())
|
||||
})
|
||||
|
||||
describe('when find succeeds', function() {
|
||||
describe('when user project found', function() {
|
||||
beforeEach(function() {
|
||||
describe('when find succeeds', function () {
|
||||
describe('when user project found', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.findOne = sinon.stub().yields(null, 'project')
|
||||
return this.ProjectCollabratecDetailsHandler.isLinkedCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -129,7 +129,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call find with project and user id', function() {
|
||||
it('should call find with project and user id', function () {
|
||||
return expect(this.ProjectModel.findOne).to.have.been.calledWithMatch(
|
||||
{
|
||||
_id: ObjectId(this.projectId),
|
||||
@@ -142,13 +142,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with true', function() {
|
||||
it('should callback with true', function () {
|
||||
return expect(this.callback).to.have.been.calledWith(null, true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when user project found', function() {
|
||||
beforeEach(function() {
|
||||
describe('when user project found', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.findOne = sinon.stub().yields(null, null)
|
||||
return this.ProjectCollabratecDetailsHandler.isLinkedCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -157,14 +157,14 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with false', function() {
|
||||
it('should callback with false', function () {
|
||||
return expect(this.callback).to.have.been.calledWith(null, false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when find has error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when find has error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.findOne = sinon.stub().yields('error')
|
||||
return this.ProjectCollabratecDetailsHandler.isLinkedCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -173,13 +173,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback).to.have.been.calledWith('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid args', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid args', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.findOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.isLinkedCollabratecUserProject(
|
||||
'bad-project-id',
|
||||
@@ -188,19 +188,19 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.findOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('linkCollabratecUserProject', function() {
|
||||
describe('when update succeeds', function() {
|
||||
beforeEach(function() {
|
||||
describe('linkCollabratecUserProject', function () {
|
||||
describe('when update succeeds', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields()
|
||||
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -210,7 +210,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update project model', function() {
|
||||
it('should update project model', function () {
|
||||
const query = {
|
||||
_id: this.projectId,
|
||||
collabratecUsers: {
|
||||
@@ -238,8 +238,8 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when update has error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when update has error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields('error')
|
||||
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -249,13 +249,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback).to.have.been.calledWith('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid args', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid args', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
|
||||
'bad-project-id',
|
||||
@@ -265,18 +265,18 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('setCollabratecUsers', function() {
|
||||
beforeEach(function() {
|
||||
describe('setCollabratecUsers', function () {
|
||||
beforeEach(function () {
|
||||
return (this.collabratecUsers = [
|
||||
{
|
||||
user_id: this.userId,
|
||||
@@ -291,8 +291,8 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
])
|
||||
})
|
||||
|
||||
describe('when update succeeds', function() {
|
||||
beforeEach(function() {
|
||||
describe('when update succeeds', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields()
|
||||
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
|
||||
this.projectId,
|
||||
@@ -301,7 +301,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update project model', function() {
|
||||
it('should update project model', function () {
|
||||
const update = {
|
||||
$set: {
|
||||
collabratecUsers: this.collabratecUsers
|
||||
@@ -315,8 +315,8 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when update has error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when update has error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields('error')
|
||||
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
|
||||
this.projectId,
|
||||
@@ -325,13 +325,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback).to.have.been.calledWith('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid project_id', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid project_id', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
|
||||
'bad-project-id',
|
||||
@@ -340,17 +340,17 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid user_id', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid user_id', function () {
|
||||
beforeEach(function () {
|
||||
this.collabratecUsers[1].user_id = 'bad-user-id'
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.setCollabratecUsers(
|
||||
@@ -360,19 +360,19 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('unlinkCollabratecUserProject', function() {
|
||||
describe('when update succeeds', function() {
|
||||
beforeEach(function() {
|
||||
describe('unlinkCollabratecUserProject', function () {
|
||||
describe('when update succeeds', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields()
|
||||
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -381,7 +381,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update project model', function() {
|
||||
it('should update project model', function () {
|
||||
const query = { _id: this.projectId }
|
||||
const update = {
|
||||
$pull: {
|
||||
@@ -398,8 +398,8 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when update has error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when update has error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub().yields('error')
|
||||
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
|
||||
this.projectId,
|
||||
@@ -408,13 +408,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback).to.have.been.calledWith('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid args', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid args', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
|
||||
'bad-project-id',
|
||||
@@ -423,19 +423,19 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('updateCollabratecUserIds', function() {
|
||||
describe('when update succeeds', function() {
|
||||
beforeEach(function() {
|
||||
describe('updateCollabratecUserIds', function () {
|
||||
describe('when update succeeds', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateMany = sinon.stub().yields()
|
||||
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
|
||||
this.userId,
|
||||
@@ -444,7 +444,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update project model', function() {
|
||||
it('should update project model', function () {
|
||||
return expect(this.ProjectModel.updateMany).to.have.been.calledWith(
|
||||
{ 'collabratecUsers.user_id': this.userId },
|
||||
{ $set: { 'collabratecUsers.$.user_id': this.userId2 } },
|
||||
@@ -453,8 +453,8 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when update has error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when update has error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateMany = sinon.stub().yields('error')
|
||||
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
|
||||
this.userId,
|
||||
@@ -463,13 +463,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback).to.have.been.calledWith('error')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid old_user_id', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid old_user_id', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
|
||||
'bad-user-id',
|
||||
@@ -478,17 +478,17 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid new_user_id', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid new_user_id', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
|
||||
this.userId,
|
||||
@@ -497,11 +497,11 @@ describe('ProjectCollabratecDetailsHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not update', function() {
|
||||
it('should not update', function () {
|
||||
return expect(this.ProjectModel.updateOne).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('should callback with error', function() {
|
||||
it('should callback with error', function () {
|
||||
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user