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
@@ -37,8 +37,8 @@ const mockSubscriptions = {
}
}
describe('SubscriptionController', function() {
beforeEach(function() {
describe('SubscriptionController', function () {
beforeEach(function () {
this.user = {
email: 'tom@yahoo.com',
_id: 'one',
@@ -126,8 +126,8 @@ describe('SubscriptionController', function() {
return (this.stubbedCurrencyCode = 'GBP')
})
describe('plansPage', function() {
beforeEach(function() {
describe('plansPage', function () {
beforeEach(function () {
this.req.ip = '1234.3123.3131.333 313.133.445.666 653.5345.5345.534'
return this.GeoIpLookup.getCurrencyCode.callsArgWith(
1,
@@ -136,19 +136,19 @@ describe('SubscriptionController', function() {
)
})
describe('when user is logged in', function(done) {
beforeEach(function(done) {
describe('when user is logged in', function (done) {
beforeEach(function (done) {
this.res.callback = done
return this.SubscriptionController.plansPage(this.req, this.res)
})
it('should fetch the current user', function(done) {
it('should fetch the current user', function (done) {
this.UserGetter.getUser.callCount.should.equal(1)
return done()
})
describe('not dependant on logged in state', function(done) {
describe('not dependant on logged in state', function (done) {
// these could have been put in 'when user is not logged in' too
it('should set the recommended currency from the geoiplookup', function(done) {
it('should set the recommended currency from the geoiplookup', function (done) {
this.res.renderedVariables.recomendedCurrency.should.equal(
this.stubbedCurrencyCode
)
@@ -157,15 +157,15 @@ describe('SubscriptionController', function() {
.should.equal(true)
return done()
})
it('should include data for features table', function(done) {
it('should include data for features table', function (done) {
this.res.renderedVariables.planFeatures.length.should.not.equal(0)
return done()
})
})
})
describe('when user is not logged in', function(done) {
beforeEach(function(done) {
describe('when user is not logged in', function (done) {
beforeEach(function (done) {
this.res.callback = done
this.AuthenticationController.getLoggedInUserId = sinon
.stub()
@@ -173,15 +173,15 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.plansPage(this.req, this.res)
})
it('should not fetch the current user', function(done) {
it('should not fetch the current user', function (done) {
this.UserGetter.getUser.callCount.should.equal(0)
return done()
})
})
})
describe('paymentPage', function() {
beforeEach(function() {
describe('paymentPage', function () {
beforeEach(function () {
this.req.headers = {}
this.SubscriptionHandler.validateNoSubscriptionInRecurly = sinon
.stub()
@@ -193,8 +193,8 @@ describe('SubscriptionController', function() {
)
})
describe('with a user without a subscription', function() {
beforeEach(function() {
describe('with a user without a subscription', function () {
beforeEach(function () {
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
1,
null,
@@ -203,8 +203,8 @@ describe('SubscriptionController', function() {
return this.PlansLocator.findLocalPlanInSettings.returns({})
})
describe('with a valid plan code', function() {
it('should render the new subscription page', function(done) {
describe('with a valid plan code', function () {
it('should render the new subscription page', function (done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/new')
return done()
@@ -214,8 +214,8 @@ describe('SubscriptionController', function() {
})
})
describe('with a user with subscription', function() {
it('should redirect to the subscription dashboard', function(done) {
describe('with a user with subscription', function () {
it('should redirect to the subscription dashboard', function (done) {
this.PlansLocator.findLocalPlanInSettings.returns({})
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
1,
@@ -230,8 +230,8 @@ describe('SubscriptionController', function() {
})
})
describe('with an invalid plan code', function() {
it('should return 422 error - Unprocessable Entity', function(done) {
describe('with an invalid plan code', function () {
it('should return 422 error - Unprocessable Entity', function (done) {
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
1,
null,
@@ -254,8 +254,8 @@ describe('SubscriptionController', function() {
})
})
describe('which currency to use', function() {
beforeEach(function() {
describe('which currency to use', function () {
beforeEach(function () {
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
1,
null,
@@ -264,7 +264,7 @@ describe('SubscriptionController', function() {
return this.PlansLocator.findLocalPlanInSettings.returns({})
})
it('should use the set currency from the query string', function(done) {
it('should use the set currency from the query string', function (done) {
this.req.query.currency = 'EUR'
this.res.render = (page, opts) => {
opts.currency.should.equal('EUR')
@@ -274,7 +274,7 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.paymentPage(this.req, this.res)
})
it('should upercase the currency code', function(done) {
it('should upercase the currency code', function (done) {
this.req.query.currency = 'eur'
this.res.render = (page, opts) => {
opts.currency.should.equal('EUR')
@@ -283,7 +283,7 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.paymentPage(this.req, this.res)
})
it('should use the geo ip currency if non is provided', function(done) {
it('should use the geo ip currency if non is provided', function (done) {
this.req.query.currency = null
this.res.render = (page, opts) => {
opts.currency.should.equal(this.stubbedCurrencyCode)
@@ -293,8 +293,8 @@ describe('SubscriptionController', function() {
})
})
describe('with a recurly subscription already', function() {
it('should redirect to the subscription dashboard', function(done) {
describe('with a recurly subscription already', function () {
it('should redirect to the subscription dashboard', function (done) {
this.PlansLocator.findLocalPlanInSettings.returns({})
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
1,
@@ -313,8 +313,8 @@ describe('SubscriptionController', function() {
})
})
describe('successful_subscription', function() {
beforeEach(function(done) {
describe('successful_subscription', function () {
beforeEach(function (done) {
this.SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel.callsArgWith(
1,
null,
@@ -328,8 +328,8 @@ describe('SubscriptionController', function() {
})
})
describe('userSubscriptionPage', function() {
beforeEach(function(done) {
describe('userSubscriptionPage', function () {
beforeEach(function (done) {
this.SubscriptionViewModelBuilder.buildUsersSubscriptionViewModel.callsArgWith(
1,
null,
@@ -361,7 +361,7 @@ describe('SubscriptionController', function() {
)
})
it('should load the personal, groups and v1 subscriptions', function() {
it('should load the personal, groups and v1 subscriptions', function () {
expect(this.data.personalSubscription).to.deep.equal(
this.personalSubscription
)
@@ -370,17 +370,17 @@ describe('SubscriptionController', function() {
)
})
it('should load the user', function() {
it('should load the user', function () {
return expect(this.data.user).to.deep.equal(this.user)
})
it('should load the plans', function() {
it('should load the plans', function () {
return expect(this.data.plans).to.deep.equal(this.plans)
})
})
describe('createSubscription', function() {
beforeEach(function(done) {
describe('createSubscription', function () {
beforeEach(function (done) {
this.res = {
sendStatus() {
return done()
@@ -402,7 +402,7 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.createSubscription(this.req, this.res)
})
it('should send the user and subscriptionId to the handler', function(done) {
it('should send the user and subscriptionId to the handler', function (done) {
this.SubscriptionHandler.createSubscription
.calledWithMatch(
this.user,
@@ -413,14 +413,14 @@ describe('SubscriptionController', function() {
return done()
})
it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function (done) {
this.res.sendStatus.calledWith(201).should.equal(true)
return done()
})
})
describe('createSubscription with errors', function() {
it('should handle users with subscription', function(done) {
describe('createSubscription with errors', function () {
it('should handle users with subscription', function (done) {
this.LimitationsManager.userHasV1OrV2Subscription.yields(null, true)
this.SubscriptionController.createSubscription(this.req, {
sendStatus: status => {
@@ -432,7 +432,7 @@ describe('SubscriptionController', function() {
})
})
it('should handle 3DSecure errors', function(done) {
it('should handle 3DSecure errors', function (done) {
this.next = sinon.stub()
this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)
this.SubscriptionHandler.createSubscription.yields(
@@ -449,7 +449,7 @@ describe('SubscriptionController', function() {
this.SubscriptionController.createSubscription(this.req, this.res)
})
it('should handle validation errors', function(done) {
it('should handle validation errors', function (done) {
this.next = sinon.stub()
this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)
this.SubscriptionHandler.createSubscription.yields(
@@ -466,7 +466,7 @@ describe('SubscriptionController', function() {
this.SubscriptionController.createSubscription(this.req, this.res)
})
it('should handle recurly errors', function(done) {
it('should handle recurly errors', function (done) {
this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)
this.SubscriptionHandler.createSubscription.yields(
new SubscriptionErrors.RecurlyTransactionError({})
@@ -484,7 +484,7 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.createSubscription(this.req, this.res)
})
it('should handle invalid error', function(done) {
it('should handle invalid error', function (done) {
this.LimitationsManager.userHasV1OrV2Subscription.yields(null, false)
this.SubscriptionHandler.createSubscription.yields(
new Errors.InvalidError({})
@@ -500,8 +500,8 @@ describe('SubscriptionController', function() {
})
})
describe('updateSubscription via post', function() {
beforeEach(function(done) {
describe('updateSubscription via post', function () {
beforeEach(function (done) {
this.res = {
redirect() {
return done()
@@ -513,21 +513,21 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.updateSubscription(this.req, this.res)
})
it('should send the user and subscriptionId to the handler', function(done) {
it('should send the user and subscriptionId to the handler', function (done) {
this.SubscriptionHandler.updateSubscription
.calledWith(this.user, this.plan_code)
.should.equal(true)
return done()
})
it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function (done) {
this.res.redirect.calledWith('/user/subscription').should.equal(true)
return done()
})
})
describe('updateAccountEmailAddress via put', function() {
it('should send the user and subscriptionId to RecurlyWrapper', function() {
describe('updateAccountEmailAddress via put', function () {
it('should send the user and subscriptionId to RecurlyWrapper', function () {
this.res.sendStatus = sinon.spy()
this.SubscriptionController.updateAccountEmailAddress(this.req, this.res)
this.RecurlyWrapper.updateAccountEmailAddress
@@ -535,13 +535,13 @@ describe('SubscriptionController', function() {
.should.equal(true)
})
it('should respond with 200', function() {
it('should respond with 200', function () {
this.res.sendStatus = sinon.spy()
this.SubscriptionController.updateAccountEmailAddress(this.req, this.res)
this.res.sendStatus.calledWith(200).should.equal(true)
})
it('should send the error to the next handler when updating recurly account email fails', function(done) {
it('should send the error to the next handler when updating recurly account email fails', function (done) {
this.RecurlyWrapper.updateAccountEmailAddress.yields(new Error())
this.next = sinon.spy(error => {
expect(error).instanceOf(Error)
@@ -555,8 +555,8 @@ describe('SubscriptionController', function() {
})
})
describe('reactivateSubscription', function() {
beforeEach(function(done) {
describe('reactivateSubscription', function () {
beforeEach(function (done) {
this.res = {
redirect() {
return done()
@@ -569,21 +569,21 @@ describe('SubscriptionController', function() {
)
})
it('should tell the handler to reactivate this user', function(done) {
it('should tell the handler to reactivate this user', function (done) {
this.SubscriptionHandler.reactivateSubscription
.calledWith(this.user)
.should.equal(true)
return done()
})
it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function (done) {
this.res.redirect.calledWith('/user/subscription').should.equal(true)
return done()
})
})
describe('cancelSubscription', function() {
beforeEach(function(done) {
describe('cancelSubscription', function () {
beforeEach(function (done) {
this.res = {
redirect() {
return done()
@@ -593,14 +593,14 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.cancelSubscription(this.req, this.res)
})
it('should tell the handler to cancel this user', function(done) {
it('should tell the handler to cancel this user', function (done) {
this.SubscriptionHandler.cancelSubscription
.calledWith(this.user)
.should.equal(true)
return done()
})
it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function (done) {
this.res.redirect
.calledWith('/user/subscription/canceled')
.should.equal(true)
@@ -608,9 +608,9 @@ describe('SubscriptionController', function() {
})
})
describe('recurly callback', function() {
describe('with a sync subscription request', function() {
beforeEach(function(done) {
describe('recurly callback', function () {
describe('with a sync subscription request', function () {
beforeEach(function (done) {
this.req = {
body: {
expired_subscription_notification: {
@@ -629,19 +629,19 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.recurlyCallback(this.req, this.res)
})
it('should tell the SubscriptionHandler to process the recurly callback', function(done) {
it('should tell the SubscriptionHandler to process the recurly callback', function (done) {
this.SubscriptionHandler.syncSubscription.called.should.equal(true)
return done()
})
it('should send a 200', function(done) {
it('should send a 200', function (done) {
this.res.sendStatus.calledWith(200)
return done()
})
})
describe('with a billing info updated request', function() {
beforeEach(function(done) {
describe('with a billing info updated request', function () {
beforeEach(function (done) {
this.req = {
body: {
billing_info_updated_notification: {
@@ -660,21 +660,21 @@ describe('SubscriptionController', function() {
this.SubscriptionController.recurlyCallback(this.req, this.res)
})
it('should call attemptPaypalInvoiceCollection', function(done) {
it('should call attemptPaypalInvoiceCollection', function (done) {
this.SubscriptionHandler.attemptPaypalInvoiceCollection
.calledWith('mock-account-code')
.should.equal(true)
done()
})
it('should send a 200', function(done) {
it('should send a 200', function (done) {
this.res.sendStatus.calledWith(200)
done()
})
})
describe('with a non-actionable request', function() {
beforeEach(function(done) {
describe('with a non-actionable request', function () {
beforeEach(function (done) {
this.user.id = this.activeRecurlySubscription.account.account_code
this.req = {
body: {
@@ -694,23 +694,23 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.recurlyCallback(this.req, this.res)
})
it('should not call the subscriptionshandler', function() {
it('should not call the subscriptionshandler', function () {
this.SubscriptionHandler.syncSubscription.called.should.equal(false)
this.SubscriptionHandler.attemptPaypalInvoiceCollection.called.should.equal(
false
)
})
it('should respond with a 200 status', function() {
it('should respond with a 200 status', function () {
return this.res.sendStatus.calledWith(200)
})
})
})
describe('renderUpgradeToAnnualPlanPage', function() {
it('should redirect to the plans page if the user does not have a subscription', function(done) {
describe('renderUpgradeToAnnualPlanPage', function () {
it('should redirect to the plans page if the user does not have a subscription', function (done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false)
this.res.redirect = function(url) {
this.res.redirect = function (url) {
url.should.equal('/user/subscription/plans')
return done()
}
@@ -720,14 +720,14 @@ describe('SubscriptionController', function() {
)
})
it('should pass the plan code to the view - student', function(done) {
it('should pass the plan code to the view - student', function (done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(
1,
null,
true,
{ planCode: 'Student free trial 14 days' }
)
this.res.render = function(view, opts) {
this.res.render = function (view, opts) {
view.should.equal('subscriptions/upgradeToAnnual')
opts.planName.should.equal('student')
return done()
@@ -738,14 +738,14 @@ describe('SubscriptionController', function() {
)
})
it('should pass the plan code to the view - collaborator', function(done) {
it('should pass the plan code to the view - collaborator', function (done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(
1,
null,
true,
{ planCode: 'free trial for Collaborator free trial 14 days' }
)
this.res.render = function(view, opts) {
this.res.render = function (view, opts) {
opts.planName.should.equal('collaborator')
return done()
}
@@ -755,14 +755,14 @@ describe('SubscriptionController', function() {
)
})
it('should pass annual as the plan name if the user is already on an annual plan', function(done) {
it('should pass annual as the plan name if the user is already on an annual plan', function (done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(
1,
null,
true,
{ planCode: 'student annual with free trial' }
)
this.res.render = function(view, opts) {
this.res.render = function (view, opts) {
opts.planName.should.equal('annual')
return done()
}
@@ -773,10 +773,10 @@ describe('SubscriptionController', function() {
})
})
describe('processUpgradeToAnnualPlan', function() {
beforeEach(function() {})
describe('processUpgradeToAnnualPlan', function () {
beforeEach(function () {})
it('should tell the subscription handler to update the subscription with the annual plan and apply a coupon code', function(done) {
it('should tell the subscription handler to update the subscription with the annual plan and apply a coupon code', function (done) {
this.req.body = { planName: 'student' }
this.res.sendStatus = () => {
@@ -792,7 +792,7 @@ describe('SubscriptionController', function() {
)
})
it('should get the collaborator coupon code', function(done) {
it('should get the collaborator coupon code', function (done) {
this.req.body = { planName: 'collaborator' }
this.res.sendStatus = url => {