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
@@ -21,7 +21,7 @@ const modulePath = require('path').join(
'../../../../app/src/Features/Exports/ExportsController.js'
)
describe('ExportsController', function() {
describe('ExportsController', function () {
const project_id = '123njdskj9jlk'
const user_id = '123nd3ijdks'
const brand_variation_id = 22
@@ -33,7 +33,7 @@ describe('ExportsController', function() {
const license = 'other'
const show_source = true
beforeEach(function() {
beforeEach(function () {
this.handler = { getUserNotifications: sinon.stub().callsArgWith(1) }
this.req = {
params: {
@@ -71,8 +71,8 @@ describe('ExportsController', function() {
}))
})
describe('without gallery fields', function() {
it('should ask the handler to perform the export', function(done) {
describe('without gallery fields', function () {
it('should ask the handler to perform the export', function (done) {
this.handler.exportProject = sinon
.stub()
.yields(null, { iAmAnExport: true, v1_id: 897 })
@@ -93,8 +93,8 @@ describe('ExportsController', function() {
})
})
describe('with a message from v1', function() {
it('should ask the handler to perform the export', function(done) {
describe('with a message from v1', function () {
it('should ask the handler to perform the export', function (done) {
this.handler.exportProject = sinon.stub().yields(null, {
iAmAnExport: true,
v1_id: 897,
@@ -120,8 +120,8 @@ describe('ExportsController', function() {
})
})
describe('with gallery fields', function() {
beforeEach(function() {
describe('with gallery fields', function () {
beforeEach(function () {
this.req.body.title = title
this.req.body.description = description
this.req.body.author = author
@@ -129,7 +129,7 @@ describe('ExportsController', function() {
return (this.req.body.showSource = true)
})
it('should ask the handler to perform the export', function(done) {
it('should ask the handler to perform the export', function (done) {
this.handler.exportProject = sinon
.stub()
.yields(null, { iAmAnExport: true, v1_id: 897 })
@@ -155,8 +155,8 @@ describe('ExportsController', function() {
})
})
describe('with an error return from v1 to forward to the publish modal', function() {
it('should forward the response onward', function(done) {
describe('with an error return from v1 to forward to the publish modal', function () {
it('should forward the response onward', function (done) {
this.error_json = { status: 422, message: 'nope' }
this.handler.exportProject = sinon
.stub()
@@ -168,7 +168,7 @@ describe('ExportsController', function() {
})
})
it('should ask the handler to return the status of an export', function(done) {
it('should ask the handler to return the status of an export', function (done) {
this.handler.fetchExport = sinon.stub().yields(
null,
`{ \
@@ -16,8 +16,8 @@ const { expect } = require('chai')
const modulePath = '../../../../app/src/Features/Exports/ExportsHandler.js'
const SandboxedModule = require('sandboxed-module')
describe('ExportsHandler', function() {
beforeEach(function() {
describe('ExportsHandler', function () {
beforeEach(function () {
this.stubRequest = {}
this.request = {
defaults: () => {
@@ -57,8 +57,8 @@ describe('ExportsHandler', function() {
return (this.callback = sinon.stub())
})
describe('exportProject', function() {
beforeEach(function() {
describe('exportProject', function () {
beforeEach(function () {
this.export_data = { iAmAnExport: true }
this.response_body = { iAmAResponseBody: true }
this.ExportsHandler._buildExport = sinon
@@ -69,8 +69,8 @@ describe('ExportsHandler', function() {
.yields(null, this.response_body))
})
describe('when all goes well', function() {
beforeEach(function(done) {
describe('when all goes well', function () {
beforeEach(function (done) {
return this.ExportsHandler.exportProject(
this.export_params,
(error, export_data) => {
@@ -80,27 +80,27 @@ describe('ExportsHandler', function() {
)
})
it('should build the export', function() {
it('should build the export', function () {
return this.ExportsHandler._buildExport
.calledWith(this.export_params)
.should.equal(true)
})
it('should request the export', function() {
it('should request the export', function () {
return this.ExportsHandler._requestExport
.calledWith(this.export_data)
.should.equal(true)
})
it('should return the export', function() {
it('should return the export', function () {
return this.callback
.calledWith(null, this.export_data)
.should.equal(true)
})
})
describe("when request can't be built", function() {
beforeEach(function(done) {
describe("when request can't be built", function () {
beforeEach(function (done) {
this.ExportsHandler._buildExport = sinon
.stub()
.yields(new Error('cannot export project without root doc'))
@@ -113,13 +113,13 @@ describe('ExportsHandler', function() {
)
})
it('should return an error', function() {
it('should return an error', function () {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
describe('when export request returns an error to forward to the user', function() {
beforeEach(function(done) {
describe('when export request returns an error to forward to the user', function () {
beforeEach(function (done) {
this.error_json = { status: 422, message: 'nope' }
this.ExportsHandler._requestExport = sinon
.stub()
@@ -133,7 +133,7 @@ describe('ExportsHandler', function() {
)
})
it('should return success and the response to forward', function() {
it('should return success and the response to forward', function () {
;(this.callback.args[0][0] instanceof Error).should.equal(false)
return this.callback.calledWith(null, {
forwardResponse: this.error_json
@@ -142,8 +142,8 @@ describe('ExportsHandler', function() {
})
})
describe('_buildExport', function() {
beforeEach(function(done) {
describe('_buildExport', function () {
beforeEach(function (done) {
this.project = {
id: this.project_id,
rootDoc_id: 'doc1_id',
@@ -184,8 +184,8 @@ describe('ExportsHandler', function() {
return done()
})
describe('when all goes well', function() {
beforeEach(function(done) {
describe('when all goes well', function () {
beforeEach(function (done) {
return this.ExportsHandler._buildExport(
this.export_params,
(error, export_data) => {
@@ -195,17 +195,17 @@ describe('ExportsHandler', function() {
)
})
it('should ensure the project has history', function() {
it('should ensure the project has history', function () {
return this.ProjectHistoryHandler.ensureHistoryExistsForProject.called.should.equal(
true
)
})
it('should request the project history version', function() {
it('should request the project history version', function () {
return this.ExportsHandler._requestVersion.called.should.equal(true)
})
it('should return export data', function() {
it('should return export data', function () {
const expected_export_data = {
project: {
id: this.project_id,
@@ -244,8 +244,8 @@ describe('ExportsHandler', function() {
})
})
describe('when we send replacement user first and last name', function() {
beforeEach(function(done) {
describe('when we send replacement user first and last name', function () {
beforeEach(function (done) {
this.custom_first_name = 'FIRST'
this.custom_last_name = 'LAST'
this.export_params.first_name = this.custom_first_name
@@ -259,7 +259,7 @@ describe('ExportsHandler', function() {
)
})
it('should send the data from the user input', function() {
it('should send the data from the user input', function () {
const expected_export_data = {
project: {
id: this.project_id,
@@ -298,8 +298,8 @@ describe('ExportsHandler', function() {
})
})
describe('when project is not found', function() {
beforeEach(function(done) {
describe('when project is not found', function () {
beforeEach(function (done) {
this.ProjectGetter.getProject = sinon
.stub()
.yields(new Error('project not found'))
@@ -312,14 +312,14 @@ describe('ExportsHandler', function() {
)
})
it('should return an error', function() {
it('should return an error', function () {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
describe('when project has no root doc', function() {
describe('when a root doc can be set automatically', function() {
beforeEach(function(done) {
describe('when project has no root doc', function () {
describe('when a root doc can be set automatically', function () {
beforeEach(function (done) {
this.project.rootDoc_id = null
this.ProjectLocator.findRootDoc = sinon
.stub()
@@ -333,13 +333,13 @@ describe('ExportsHandler', function() {
)
})
it('should set a root doc', function() {
it('should set a root doc', function () {
return this.ProjectRootDocManager.ensureRootDocumentIsValid.called.should.equal(
true
)
})
it('should return export data', function() {
it('should return export data', function () {
const expected_export_data = {
project: {
id: this.project_id,
@@ -379,9 +379,9 @@ describe('ExportsHandler', function() {
})
})
describe('when project has an invalid root doc', function() {
describe('when a new root doc can be set automatically', function() {
beforeEach(function(done) {
describe('when project has an invalid root doc', function () {
describe('when a new root doc can be set automatically', function () {
beforeEach(function (done) {
this.fakeDoc_id = '1a2b3c4d5e6f'
this.project.rootDoc_id = this.fakeDoc_id
this.ProjectLocator.findRootDoc = sinon
@@ -396,13 +396,13 @@ describe('ExportsHandler', function() {
)
})
it('should set a valid root doc', function() {
it('should set a valid root doc', function () {
return this.ProjectRootDocManager.ensureRootDocumentIsValid.called.should.equal(
true
)
})
it('should return export data', function() {
it('should return export data', function () {
const expected_export_data = {
project: {
id: this.project_id,
@@ -441,8 +441,8 @@ describe('ExportsHandler', function() {
})
})
describe('when no root doc can be identified', function() {
beforeEach(function(done) {
describe('when no root doc can be identified', function () {
beforeEach(function (done) {
this.ProjectLocator.findRootDoc = sinon
.stub()
.yields(null, [null, null])
@@ -455,14 +455,14 @@ describe('ExportsHandler', function() {
)
})
it('should return an error', function() {
it('should return an error', function () {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
})
describe('when user is not found', function() {
beforeEach(function(done) {
describe('when user is not found', function () {
beforeEach(function (done) {
this.UserGetter.getUser = sinon
.stub()
.yields(new Error('user not found'))
@@ -475,13 +475,13 @@ describe('ExportsHandler', function() {
)
})
it('should return an error', function() {
it('should return an error', function () {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
describe('when project history request fails', function() {
beforeEach(function(done) {
describe('when project history request fails', function () {
beforeEach(function (done) {
this.ExportsHandler._requestVersion = sinon
.stub()
.yields(new Error('project history call failed'))
@@ -494,14 +494,14 @@ describe('ExportsHandler', function() {
)
})
it('should return an error', function() {
it('should return an error', function () {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
})
describe('_requestExport', function() {
beforeEach(function(done) {
describe('_requestExport', function () {
beforeEach(function (done) {
this.settings.apis = {
v1: {
url: 'http://localhost:5000',
@@ -517,8 +517,8 @@ describe('ExportsHandler', function() {
return done()
})
describe('when all goes well', function() {
beforeEach(function(done) {
describe('when all goes well', function () {
beforeEach(function (done) {
this.stubRequest.post = this.stubPost
return this.ExportsHandler._requestExport(
this.export_data,
@@ -529,7 +529,7 @@ describe('ExportsHandler', function() {
)
})
it('should issue the request', function() {
it('should issue the request', function () {
return expect(this.stubPost.getCall(0).args[0]).to.deep.equal({
url: this.settings.apis.v1.url + '/api/v1/sharelatex/exports',
auth: {
@@ -540,15 +540,15 @@ describe('ExportsHandler', function() {
})
})
it('should return the body with v1 export id', function() {
it('should return the body with v1 export id', function () {
return this.callback
.calledWith(null, { exportId: this.export_id })
.should.equal(true)
})
})
describe('when the request fails', function() {
beforeEach(function(done) {
describe('when the request fails', function () {
beforeEach(function (done) {
this.stubRequest.post = sinon
.stub()
.yields(new Error('export request failed'))
@@ -561,13 +561,13 @@ describe('ExportsHandler', function() {
)
})
it('should return an error', function() {
it('should return an error', function () {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
describe('when the request returns an error response to forward', function() {
beforeEach(function(done) {
describe('when the request returns an error response to forward', function () {
beforeEach(function (done) {
this.error_code = 422
this.error_json = { status: this.error_code, message: 'nope' }
this.stubRequest.post = sinon
@@ -582,7 +582,7 @@ describe('ExportsHandler', function() {
)
})
it('should return success and the response to forward', function() {
it('should return success and the response to forward', function () {
;(this.callback.args[0][0] instanceof Error).should.equal(false)
return this.callback.calledWith(null, {
forwardResponse: this.error_json
@@ -591,8 +591,8 @@ describe('ExportsHandler', function() {
})
})
describe('fetchExport', function() {
beforeEach(function(done) {
describe('fetchExport', function () {
beforeEach(function (done) {
this.settings.apis = {
v1: {
url: 'http://localhost:5000',
@@ -608,8 +608,8 @@ describe('ExportsHandler', function() {
return done()
})
describe('when all goes well', function() {
beforeEach(function(done) {
describe('when all goes well', function () {
beforeEach(function (done) {
this.stubRequest.get = this.stubGet
return this.ExportsHandler.fetchExport(
this.export_id,
@@ -620,7 +620,7 @@ describe('ExportsHandler', function() {
)
})
it('should issue the request', function() {
it('should issue the request', function () {
return expect(this.stubGet.getCall(0).args[0]).to.deep.equal({
url:
this.settings.apis.v1.url +
@@ -633,7 +633,7 @@ describe('ExportsHandler', function() {
})
})
it('should return the v1 export id', function() {
it('should return the v1 export id', function () {
return this.callback
.calledWith(null, { body: this.body })
.should.equal(true)
@@ -641,8 +641,8 @@ describe('ExportsHandler', function() {
})
})
describe('fetchDownload', function() {
beforeEach(function(done) {
describe('fetchDownload', function () {
beforeEach(function (done) {
this.settings.apis = {
v1: {
url: 'http://localhost:5000',
@@ -659,8 +659,8 @@ describe('ExportsHandler', function() {
return done()
})
describe('when all goes well', function() {
beforeEach(function(done) {
describe('when all goes well', function () {
beforeEach(function (done) {
this.stubRequest.get = this.stubGet
return this.ExportsHandler.fetchDownload(
this.export_id,
@@ -672,7 +672,7 @@ describe('ExportsHandler', function() {
)
})
it('should issue the request', function() {
it('should issue the request', function () {
return expect(this.stubGet.getCall(0).args[0]).to.deep.equal({
url:
this.settings.apis.v1.url +
@@ -686,7 +686,7 @@ describe('ExportsHandler', function() {
})
})
it('should return the v1 export id', function() {
it('should return the v1 export id', function () {
return this.callback
.calledWith(null, { body: this.body })
.should.equal(true)