Merge pull request #3495 from overleaf/ae-prettier-2

Upgrade Prettier to v2

GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
Alf Eaton
2021-04-14 14:17:21 +01:00
committed by Copybot
parent 930d7ba028
commit 1ebc8a79cb
582 changed files with 20382 additions and 20374 deletions

View File

@@ -4,8 +4,8 @@ const modulePath = '../../../../app/src/Features/Project/ProjectGetter.js'
const SandboxedModule = require('sandboxed-module')
const { ObjectId } = require('mongodb')
describe('ProjectGetter', function() {
beforeEach(function() {
describe('ProjectGetter', function () {
beforeEach(function () {
this.callback = sinon.stub()
this.project = { _id: new ObjectId() }
this.projectIdStr = this.project._id.toString()
@@ -61,26 +61,26 @@ describe('ProjectGetter', function() {
})
})
describe('getProjectWithoutDocLines', function() {
beforeEach(function() {
describe('getProjectWithoutDocLines', function () {
beforeEach(function () {
this.ProjectGetter.getProject = sinon.stub().yields()
})
describe('passing an id', function() {
beforeEach(function() {
describe('passing an id', function () {
beforeEach(function () {
this.ProjectGetter.getProjectWithoutDocLines(
this.project._id,
this.callback
)
})
it('should call find with the project id', function() {
it('should call find with the project id', function () {
this.ProjectGetter.getProject
.calledWith(this.project._id)
.should.equal(true)
})
it('should exclude the doc lines', function() {
it('should exclude the doc lines', function () {
const excludes = {
'rootFolder.docs.lines': 0,
'rootFolder.folders.docs.lines': 0,
@@ -97,32 +97,32 @@ describe('ProjectGetter', function() {
.should.equal(true)
})
it('should call the callback', function() {
it('should call the callback', function () {
this.callback.called.should.equal(true)
})
})
})
describe('getProjectWithOnlyFolders', function() {
beforeEach(function() {
describe('getProjectWithOnlyFolders', function () {
beforeEach(function () {
this.ProjectGetter.getProject = sinon.stub().yields()
})
describe('passing an id', function() {
beforeEach(function() {
describe('passing an id', function () {
beforeEach(function () {
this.ProjectGetter.getProjectWithOnlyFolders(
this.project._id,
this.callback
)
})
it('should call find with the project id', function() {
it('should call find with the project id', function () {
this.ProjectGetter.getProject
.calledWith(this.project._id)
.should.equal(true)
})
it('should exclude the docs and files linesaaaa', function() {
it('should exclude the docs and files linesaaaa', function () {
const excludes = {
'rootFolder.docs': 0,
'rootFolder.fileRefs': 0,
@@ -146,20 +146,20 @@ describe('ProjectGetter', function() {
.should.equal(true)
})
it('should call the callback with the project', function() {
it('should call the callback with the project', function () {
this.callback.called.should.equal(true)
})
})
})
describe('getProject', function() {
describe('without projection', function() {
describe('with project id', function() {
beforeEach(function() {
describe('getProject', function () {
describe('without projection', function () {
describe('with project id', function () {
beforeEach(function () {
this.ProjectGetter.getProject(this.projectIdStr, this.callback)
})
it('should call findOne with the project id', function() {
it('should call findOne with the project id', function () {
expect(this.db.projects.findOne.callCount).to.equal(1)
expect(
this.db.projects.findOne.lastCall.args[0]._id.toString()
@@ -167,25 +167,25 @@ describe('ProjectGetter', function() {
})
})
describe('without project id', function() {
beforeEach(function() {
describe('without project id', function () {
beforeEach(function () {
this.ProjectGetter.getProject(null, this.callback)
})
it('should callback with error', function() {
it('should callback with error', function () {
expect(this.db.projects.findOne.callCount).to.equal(0)
expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
})
})
describe('with projection', function() {
beforeEach(function() {
describe('with projection', function () {
beforeEach(function () {
this.projection = { _id: 1 }
})
describe('with project id', function() {
beforeEach(function() {
describe('with project id', function () {
beforeEach(function () {
this.ProjectGetter.getProject(
this.projectIdStr,
this.projection,
@@ -193,7 +193,7 @@ describe('ProjectGetter', function() {
)
})
it('should call findOne with the project id', function() {
it('should call findOne with the project id', function () {
expect(this.db.projects.findOne.callCount).to.equal(1)
expect(
this.db.projects.findOne.lastCall.args[0]._id.toString()
@@ -204,12 +204,12 @@ describe('ProjectGetter', function() {
})
})
describe('without project id', function() {
beforeEach(function() {
describe('without project id', function () {
beforeEach(function () {
this.ProjectGetter.getProject(null, this.callback)
})
it('should callback with error', function() {
it('should callback with error', function () {
expect(this.db.projects.findOne.callCount).to.equal(0)
expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
@@ -217,17 +217,17 @@ describe('ProjectGetter', function() {
})
})
describe('getProjectWithoutLock', function() {
describe('without projection', function() {
describe('with project id', function() {
beforeEach(function() {
describe('getProjectWithoutLock', function () {
describe('without projection', function () {
describe('with project id', function () {
beforeEach(function () {
this.ProjectGetter.getProjectWithoutLock(
this.projectIdStr,
this.callback
)
})
it('should call findOne with the project id', function() {
it('should call findOne with the project id', function () {
expect(this.db.projects.findOne.callCount).to.equal(1)
expect(
this.db.projects.findOne.lastCall.args[0]._id.toString()
@@ -235,25 +235,25 @@ describe('ProjectGetter', function() {
})
})
describe('without project id', function() {
beforeEach(function() {
describe('without project id', function () {
beforeEach(function () {
this.ProjectGetter.getProjectWithoutLock(null, this.callback)
})
it('should callback with error', function() {
it('should callback with error', function () {
expect(this.db.projects.findOne.callCount).to.equal(0)
expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
})
})
describe('with projection', function() {
beforeEach(function() {
describe('with projection', function () {
beforeEach(function () {
this.projection = { _id: 1 }
})
describe('with project id', function() {
beforeEach(function() {
describe('with project id', function () {
beforeEach(function () {
this.ProjectGetter.getProjectWithoutLock(
this.project._id,
this.projection,
@@ -261,7 +261,7 @@ describe('ProjectGetter', function() {
)
})
it('should call findOne with the project id', function() {
it('should call findOne with the project id', function () {
expect(this.db.projects.findOne.callCount).to.equal(1)
expect(
this.db.projects.findOne.lastCall.args[0]._id.toString()
@@ -272,12 +272,12 @@ describe('ProjectGetter', function() {
})
})
describe('without project id', function() {
beforeEach(function() {
describe('without project id', function () {
beforeEach(function () {
this.ProjectGetter.getProjectWithoutLock(null, this.callback)
})
it('should callback with error', function() {
it('should callback with error', function () {
expect(this.db.projects.findOne.callCount).to.equal(0)
expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
@@ -285,8 +285,8 @@ describe('ProjectGetter', function() {
})
})
describe('findAllUsersProjects', function() {
beforeEach(function() {
describe('findAllUsersProjects', function () {
beforeEach(function () {
this.fields = { mock: 'fields' }
this.Project.find
.withArgs({ owner_ref: this.userId }, this.fields)
@@ -304,7 +304,7 @@ describe('ProjectGetter', function() {
)
})
it('should call the callback with all the projects', function() {
it('should call the callback with all the projects', function () {
this.callback
.calledWith(null, {
owned: ['mock-owned-projects'],
@@ -317,28 +317,28 @@ describe('ProjectGetter', function() {
})
})
describe('getProjectIdByReadAndWriteToken', function() {
describe('when project find returns project', function() {
this.beforeEach(function() {
describe('getProjectIdByReadAndWriteToken', function () {
describe('when project find returns project', function () {
this.beforeEach(function () {
this.ProjectGetter.getProjectIdByReadAndWriteToken(
'token',
this.callback
)
})
it('should find project with token', function() {
it('should find project with token', function () {
this.Project.findOne
.calledWithMatch({ 'tokens.readAndWrite': 'token' })
.should.equal(true)
})
it('should callback with project id', function() {
it('should callback with project id', function () {
this.callback.calledWith(null, this.project._id).should.equal(true)
})
})
describe('when project not found', function() {
this.beforeEach(function() {
describe('when project not found', function () {
this.beforeEach(function () {
this.Project.findOne.yields(null, null)
this.ProjectGetter.getProjectIdByReadAndWriteToken(
'token',
@@ -346,13 +346,13 @@ describe('ProjectGetter', function() {
)
})
it('should callback empty', function() {
it('should callback empty', function () {
expect(this.callback.firstCall.args.length).to.equal(0)
})
})
describe('when project find returns error', function() {
this.beforeEach(function() {
describe('when project find returns error', function () {
this.beforeEach(function () {
this.Project.findOne.yields('error')
this.ProjectGetter.getProjectIdByReadAndWriteToken(
'token',
@@ -360,14 +360,14 @@ describe('ProjectGetter', function() {
)
})
it('should callback with error', function() {
it('should callback with error', function () {
this.callback.calledWith('error').should.equal(true)
})
})
})
describe('findUsersProjectsByName', function() {
it('should perform a case-insensitive search', function(done) {
describe('findUsersProjectsByName', function () {
it('should perform a case-insensitive search', function (done) {
this.Project.find
.withArgs({ owner_ref: this.userId })
.yields(null, [
@@ -391,7 +391,7 @@ describe('ProjectGetter', function() {
)
})
it('should search collaborations as well', function(done) {
it('should search collaborations as well', function (done) {
this.Project.find
.withArgs({ owner_ref: this.userId })
.yields(null, [{ name: 'find me!' }])
@@ -418,8 +418,8 @@ describe('ProjectGetter', function() {
})
})
describe('getUsersDeletedProjects', function() {
it('should look up the deleted projects by deletedProjectOwnerId', function(done) {
describe('getUsersDeletedProjects', function () {
it('should look up the deleted projects by deletedProjectOwnerId', function (done) {
this.ProjectGetter.getUsersDeletedProjects('giraffe', err => {
if (err) {
return done(err)
@@ -431,7 +431,7 @@ describe('ProjectGetter', function() {
})
})
it('should pass the found projects to the callback', function(done) {
it('should pass the found projects to the callback', function (done) {
this.ProjectGetter.getUsersDeletedProjects('giraffe', (err, docs) => {
if (err) {
return done(err)