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-15 02:05:22 +00:00
committed by Copybot
parent 930d7ba028
commit 1ebc8a79cb
582 changed files with 20382 additions and 20374 deletions
@@ -9,8 +9,8 @@ const { DeletedProject } = require('../helpers/models/DeletedProject')
const { ObjectId } = require('mongodb')
const Errors = require('../../../../app/src/Features/Errors/Errors')
describe('ProjectDeleter', function() {
beforeEach(function() {
describe('ProjectDeleter', function () {
beforeEach(function () {
tk.freeze(Date.now())
this.ip = '192.170.18.1'
this.project = dummyProject()
@@ -32,9 +32,7 @@ describe('ProjectDeleter', function() {
_id: '5cf7f145c1401f0ca0eb1aaa',
deleterData: {
_id: '5cf7f145c1401f0ca0eb1aac',
deletedAt: moment()
.subtract(95, 'days')
.toDate(),
deletedAt: moment().subtract(95, 'days').toDate(),
deleterId: '588f3ddae8ebc1bac07c9fa4',
deleterIpAddress: '172.19.0.1',
deletedProjectId: '5cf9270b4eff6e186cf8b05e'
@@ -52,9 +50,7 @@ describe('ProjectDeleter', function() {
_id: '5cf8eb11c1401f0ca0eb1ad7',
deleterData: {
_id: '5b74360c0fbe57011ae9938f',
deletedAt: moment()
.subtract(95, 'days')
.toDate(),
deletedAt: moment().subtract(95, 'days').toDate(),
deleterId: '588f3ddae8ebc1bac07c9fa4',
deleterIpAddress: '172.20.0.1',
deletedProjectId: '5cf8f95a0c87371362c23919'
@@ -152,14 +148,14 @@ describe('ProjectDeleter', function() {
})
})
afterEach(function() {
afterEach(function () {
tk.reset()
this.DeletedProjectMock.restore()
this.ProjectMock.restore()
})
describe('mark as deleted by external source', function() {
beforeEach(function() {
describe('mark as deleted by external source', function () {
beforeEach(function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{ _id: this.project._id },
@@ -169,14 +165,14 @@ describe('ProjectDeleter', function() {
.resolves()
})
it('should update the project with the flag set to true', async function() {
it('should update the project with the flag set to true', async function () {
await this.ProjectDeleter.promises.markAsDeletedByExternalSource(
this.project._id
)
this.ProjectMock.verify()
})
it('should tell the editor controler so users are notified', async function() {
it('should tell the editor controler so users are notified', async function () {
await this.ProjectDeleter.promises.markAsDeletedByExternalSource(
this.project._id
)
@@ -187,8 +183,8 @@ describe('ProjectDeleter', function() {
})
})
describe('unmarkAsDeletedByExternalSource', function() {
beforeEach(async function() {
describe('unmarkAsDeletedByExternalSource', function () {
beforeEach(async function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{ _id: this.project._id },
@@ -201,13 +197,13 @@ describe('ProjectDeleter', function() {
)
})
it('should remove the flag from the project', function() {
it('should remove the flag from the project', function () {
this.ProjectMock.verify()
})
})
describe('deleteUsersProjects', function() {
beforeEach(function() {
describe('deleteUsersProjects', function () {
beforeEach(function () {
this.projects = [dummyProject(), dummyProject()]
this.ProjectMock.expects('find')
.withArgs({ owner_ref: this.user._id })
@@ -235,13 +231,13 @@ describe('ProjectDeleter', function() {
}
})
it('should delete all projects owned by the user', async function() {
it('should delete all projects owned by the user', async function () {
await this.ProjectDeleter.promises.deleteUsersProjects(this.user._id)
this.ProjectMock.verify()
this.DeletedProjectMock.verify()
})
it('should remove any collaboration from this user', async function() {
it('should remove any collaboration from this user', async function () {
await this.ProjectDeleter.promises.deleteUsersProjects(this.user._id)
sinon.assert.calledWith(
this.CollaboratorsHandler.promises.removeUserFromAllProjects,
@@ -253,8 +249,8 @@ describe('ProjectDeleter', function() {
})
})
describe('deleteProject', function() {
beforeEach(function() {
describe('deleteProject', function () {
beforeEach(function () {
this.deleterData = {
deletedAt: new Date(),
deletedProjectId: this.project._id,
@@ -278,13 +274,11 @@ describe('ProjectDeleter', function() {
.resolves(this.project)
})
it('should save a DeletedProject with additional deleterData', async function() {
it('should save a DeletedProject with additional deleterData', async function () {
this.deleterData.deleterIpAddress = this.ip
this.deleterData.deleterId = this.user._id
this.ProjectMock.expects('deleteOne')
.chain('exec')
.resolves()
this.ProjectMock.expects('deleteOne').chain('exec').resolves()
this.DeletedProjectMock.expects('updateOne')
.withArgs(
{ 'deleterData.deletedProjectId': this.project._id },
@@ -303,10 +297,8 @@ describe('ProjectDeleter', function() {
this.DeletedProjectMock.verify()
})
it('should flushProjectToMongoAndDelete in doc updater', async function() {
this.ProjectMock.expects('deleteOne')
.chain('exec')
.resolves()
it('should flushProjectToMongoAndDelete in doc updater', async function () {
this.ProjectMock.expects('deleteOne').chain('exec').resolves()
this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
@@ -318,10 +310,8 @@ describe('ProjectDeleter', function() {
.should.equal(true)
})
it('should flush docs out of mongo', async function() {
this.ProjectMock.expects('deleteOne')
.chain('exec')
.resolves()
it('should flush docs out of mongo', async function () {
this.ProjectMock.expects('deleteOne').chain('exec').resolves()
this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
deleterUser: this.user,
@@ -332,10 +322,8 @@ describe('ProjectDeleter', function() {
).to.have.been.calledWith(this.project._id)
})
it('should flush docs out of mongo and ignore errors', async function() {
this.ProjectMock.expects('deleteOne')
.chain('exec')
.resolves()
it('should flush docs out of mongo and ignore errors', async function () {
this.ProjectMock.expects('deleteOne').chain('exec').resolves()
this.DeletedProjectMock.expects('updateOne').resolves()
this.DocstoreManager.promises.archiveProject.rejects(new Error('foo'))
await this.ProjectDeleter.promises.deleteProject(this.project._id, {
@@ -344,10 +332,8 @@ describe('ProjectDeleter', function() {
})
})
it('should removeProjectFromAllTags', async function() {
this.ProjectMock.expects('deleteOne')
.chain('exec')
.resolves()
it('should removeProjectFromAllTags', async function () {
this.ProjectMock.expects('deleteOne').chain('exec').resolves()
this.DeletedProjectMock.expects('updateOne').resolves()
await this.ProjectDeleter.promises.deleteProject(this.project._id)
@@ -363,7 +349,7 @@ describe('ProjectDeleter', function() {
)
})
it('should remove the project from Mongo', async function() {
it('should remove the project from Mongo', async function () {
this.ProjectMock.expects('deleteOne')
.withArgs({ _id: this.project._id })
.chain('exec')
@@ -375,8 +361,8 @@ describe('ProjectDeleter', function() {
})
})
describe('expireDeletedProjectsAfterDuration', function() {
beforeEach(async function() {
describe('expireDeletedProjectsAfterDuration', function () {
beforeEach(async function () {
this.DeletedProjectMock.expects('find')
.withArgs({
'deleterData.deletedAt': {
@@ -415,13 +401,13 @@ describe('ProjectDeleter', function() {
await this.ProjectDeleter.promises.expireDeletedProjectsAfterDuration()
})
it('should expire projects older than 90 days', function() {
it('should expire projects older than 90 days', function () {
this.DeletedProjectMock.verify()
})
})
describe('expireDeletedProject', function() {
beforeEach(async function() {
describe('expireDeletedProject', function () {
beforeEach(async function () {
this.DeletedProjectMock.expects('updateOne')
.withArgs(
{
@@ -449,17 +435,17 @@ describe('ProjectDeleter', function() {
)
})
it('should find the specified deletedProject and remove its project and ip address', function() {
it('should find the specified deletedProject and remove its project and ip address', function () {
this.DeletedProjectMock.verify()
})
it('should destroy the docs in docstore', function() {
it('should destroy the docs in docstore', function () {
expect(
this.DocstoreManager.promises.destroyProject
).to.have.been.calledWith(this.deletedProjects[0].project._id)
})
it('should delete the project in history', function() {
it('should delete the project in history', function () {
expect(
this.HistoryManager.promises.deleteProject
).to.have.been.calledWith(
@@ -468,15 +454,15 @@ describe('ProjectDeleter', function() {
)
})
it('should destroy the files in filestore', function() {
it('should destroy the files in filestore', function () {
expect(
this.FileStoreHandler.promises.deleteProject
).to.have.been.calledWith(this.deletedProjects[0].project._id)
})
})
describe('archiveProject', function() {
beforeEach(function() {
describe('archiveProject', function () {
beforeEach(function () {
let archived = [ObjectId(this.user._id)]
this.ProjectHelper.calculateArchivedArray.returns(archived)
@@ -496,7 +482,7 @@ describe('ProjectDeleter', function() {
.resolves()
})
it('should update the project', async function() {
it('should update the project', async function () {
await this.ProjectDeleter.promises.archiveProject(
this.project._id,
this.user._id
@@ -504,7 +490,7 @@ describe('ProjectDeleter', function() {
this.ProjectMock.verify()
})
it('calculates the archived array', async function() {
it('calculates the archived array', async function () {
await this.ProjectDeleter.promises.archiveProject(
this.project._id,
this.user._id
@@ -517,8 +503,8 @@ describe('ProjectDeleter', function() {
})
})
describe('unarchiveProject', function() {
beforeEach(function() {
describe('unarchiveProject', function () {
beforeEach(function () {
let archived = [ObjectId(this.user._id)]
this.ProjectHelper.calculateArchivedArray.returns(archived)
@@ -532,7 +518,7 @@ describe('ProjectDeleter', function() {
.resolves()
})
it('should update the project', async function() {
it('should update the project', async function () {
await this.ProjectDeleter.promises.unarchiveProject(
this.project._id,
this.user._id
@@ -540,7 +526,7 @@ describe('ProjectDeleter', function() {
this.ProjectMock.verify()
})
it('calculates the archived array', async function() {
it('calculates the archived array', async function () {
await this.ProjectDeleter.promises.unarchiveProject(
this.project._id,
this.user._id
@@ -553,8 +539,8 @@ describe('ProjectDeleter', function() {
})
})
describe('trashProject', function() {
beforeEach(function() {
describe('trashProject', function () {
beforeEach(function () {
let archived = [ObjectId(this.user._id)]
this.ProjectHelper.calculateArchivedArray.returns(archived)
@@ -574,7 +560,7 @@ describe('ProjectDeleter', function() {
.resolves()
})
it('should update the project', async function() {
it('should update the project', async function () {
await this.ProjectDeleter.promises.trashProject(
this.project._id,
this.user._id
@@ -582,7 +568,7 @@ describe('ProjectDeleter', function() {
this.ProjectMock.verify()
})
it('unarchives the project', async function() {
it('unarchives the project', async function () {
await this.ProjectDeleter.promises.trashProject(
this.project._id,
this.user._id
@@ -595,8 +581,8 @@ describe('ProjectDeleter', function() {
})
})
describe('untrashProject', function() {
beforeEach(function() {
describe('untrashProject', function () {
beforeEach(function () {
this.ProjectMock.expects('findOne')
.withArgs({ _id: this.project._id })
.chain('exec')
@@ -610,7 +596,7 @@ describe('ProjectDeleter', function() {
.resolves()
})
it('should update the project', async function() {
it('should update the project', async function () {
await this.ProjectDeleter.promises.untrashProject(
this.project._id,
this.user._id
@@ -619,8 +605,8 @@ describe('ProjectDeleter', function() {
})
})
describe('restoreProject', function() {
beforeEach(function() {
describe('restoreProject', function () {
beforeEach(function () {
this.ProjectMock.expects('updateOne')
.withArgs(
{
@@ -634,13 +620,13 @@ describe('ProjectDeleter', function() {
.resolves()
})
it('should unset the archive attribute', async function() {
it('should unset the archive attribute', async function () {
await this.ProjectDeleter.promises.restoreProject(this.project._id)
})
})
describe('undeleteProject', function() {
beforeEach(function() {
describe('undeleteProject', function () {
beforeEach(function () {
this.deletedProject = {
_id: 'deleted',
project: this.project,
@@ -669,24 +655,22 @@ describe('ProjectDeleter', function() {
.withArgs({ 'deleterData.deletedProjectId': 'wombat' })
.chain('exec')
.resolves(null)
this.DeletedProjectMock.expects('deleteOne')
.chain('exec')
.resolves()
this.DeletedProjectMock.expects('deleteOne').chain('exec').resolves()
})
it('should return not found if the project does not exist', async function() {
it('should return not found if the project does not exist', async function () {
await expect(
this.ProjectDeleter.promises.undeleteProject('wombat')
).to.be.rejectedWith(Errors.NotFoundError, 'project_not_found')
})
it('should return not found if the project has been expired', async function() {
it('should return not found if the project has been expired', async function () {
await expect(
this.ProjectDeleter.promises.undeleteProject('purgedProject')
).to.be.rejectedWith(Errors.NotFoundError, 'project_too_old_to_restore')
})
it('should insert the project into the collection', async function() {
it('should insert the project into the collection', async function () {
await this.ProjectDeleter.promises.undeleteProject(this.project._id)
sinon.assert.calledWith(
this.db.projects.insertOne,
@@ -697,7 +681,7 @@ describe('ProjectDeleter', function() {
)
})
it('should clear the archive bit', async function() {
it('should clear the archive bit', async function () {
this.project.archived = true
await this.ProjectDeleter.promises.undeleteProject(this.project._id)
sinon.assert.calledWith(
@@ -706,7 +690,7 @@ describe('ProjectDeleter', function() {
)
})
it('should generate a unique name for the project', async function() {
it('should generate a unique name for the project', async function () {
await this.ProjectDeleter.promises.undeleteProject(this.project._id)
sinon.assert.calledWith(
this.ProjectDetailsHandler.promises.generateUniqueName,
@@ -714,7 +698,7 @@ describe('ProjectDeleter', function() {
)
})
it('should add a suffix to the project name', async function() {
it('should add a suffix to the project name', async function () {
await this.ProjectDeleter.promises.undeleteProject(this.project._id)
sinon.assert.calledWith(
this.ProjectDetailsHandler.promises.generateUniqueName,
@@ -723,7 +707,7 @@ describe('ProjectDeleter', function() {
)
})
it('should remove the DeletedProject', async function() {
it('should remove the DeletedProject', async function () {
// need to change the mock just to include the methods we want
this.DeletedProjectMock.restore()
this.DeletedProjectMock = sinon.mock(DeletedProject)