mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 06:09:02 +02:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -19,8 +19,8 @@ const mockRecurlySubscriptions = {
|
||||
}
|
||||
}
|
||||
|
||||
describe('SubscriptionHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('SubscriptionHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.Settings = {
|
||||
plans: [
|
||||
{
|
||||
@@ -92,8 +92,8 @@ describe('SubscriptionHandler', function() {
|
||||
.callsArgWith(2)
|
||||
})
|
||||
|
||||
describe('createSubscription', function() {
|
||||
beforeEach(function() {
|
||||
describe('createSubscription', function () {
|
||||
beforeEach(function () {
|
||||
this.callback = sinon.stub()
|
||||
this.subscriptionDetails = {
|
||||
cvv: '123',
|
||||
@@ -105,8 +105,8 @@ describe('SubscriptionHandler', function() {
|
||||
.yields(null, true)
|
||||
})
|
||||
|
||||
describe('successfully', function() {
|
||||
beforeEach(function() {
|
||||
describe('successfully', function () {
|
||||
beforeEach(function () {
|
||||
this.SubscriptionHandler.createSubscription(
|
||||
this.user,
|
||||
this.subscriptionDetails,
|
||||
@@ -115,13 +115,13 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should create the subscription with the wrapper', function() {
|
||||
it('should create the subscription with the wrapper', function () {
|
||||
this.RecurlyWrapper.createSubscription
|
||||
.calledWith(this.user, this.subscriptionDetails, this.recurlyTokenIds)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should sync the subscription to the user', function() {
|
||||
it('should sync the subscription to the user', function () {
|
||||
this.SubscriptionUpdater.syncSubscription.calledOnce.should.equal(true)
|
||||
this.SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal(
|
||||
this.activeRecurlySubscription
|
||||
@@ -132,8 +132,8 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when there is already a subscription in Recurly', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there is already a subscription in Recurly', function () {
|
||||
beforeEach(function () {
|
||||
this.SubscriptionHandler.validateNoSubscriptionInRecurly = sinon
|
||||
.stub()
|
||||
.yields(null, false)
|
||||
@@ -145,7 +145,7 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should an error', function() {
|
||||
it('should an error', function () {
|
||||
this.callback.calledWith(
|
||||
new Error('user already has subscription in recurly')
|
||||
)
|
||||
@@ -153,10 +153,10 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('updateSubscription', function() {
|
||||
describe('with a user with a subscription', function() {
|
||||
describe('with a valid plan code', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('updateSubscription', function () {
|
||||
describe('with a user with a subscription', function () {
|
||||
describe('with a valid plan code', function () {
|
||||
beforeEach(function (done) {
|
||||
this.plan_code = 'collaborator'
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
1,
|
||||
@@ -172,7 +172,7 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should update the subscription', function() {
|
||||
it('should update the subscription', function () {
|
||||
this.RecurlyWrapper.updateSubscription
|
||||
.calledWith(this.subscription.recurlySubscription_id)
|
||||
.should.equal(true)
|
||||
@@ -181,13 +181,13 @@ describe('SubscriptionHandler', function() {
|
||||
updateOptions.plan_code.should.equal(this.plan_code)
|
||||
})
|
||||
|
||||
it('should update immediately', function() {
|
||||
it('should update immediately', function () {
|
||||
const updateOptions = this.RecurlyWrapper.updateSubscription
|
||||
.args[0][1]
|
||||
updateOptions.timeframe.should.equal('now')
|
||||
})
|
||||
|
||||
it('should sync the new subscription to the user', function() {
|
||||
it('should sync the new subscription to the user', function () {
|
||||
this.SubscriptionUpdater.syncSubscription.calledOnce.should.equal(
|
||||
true
|
||||
)
|
||||
@@ -201,8 +201,8 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a user without a subscription', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('with a user without a subscription', function () {
|
||||
beforeEach(function (done) {
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
@@ -216,7 +216,7 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should redirect to the subscription dashboard', function() {
|
||||
it('should redirect to the subscription dashboard', function () {
|
||||
this.RecurlyWrapper.updateSubscription.called.should.equal(false)
|
||||
this.SubscriptionHandler.syncSubscriptionToUser.called.should.equal(
|
||||
false
|
||||
@@ -224,8 +224,8 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a coupon code', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('with a coupon code', function () {
|
||||
beforeEach(function (done) {
|
||||
this.plan_code = 'collaborator'
|
||||
this.coupon_code = '1231312'
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
@@ -242,13 +242,13 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should get the users account', function() {
|
||||
it('should get the users account', function () {
|
||||
this.RecurlyWrapper.getSubscription
|
||||
.calledWith(this.activeRecurlySubscription.uuid)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should redeme the coupon', function(done) {
|
||||
it('should redeme the coupon', function (done) {
|
||||
this.RecurlyWrapper.redeemCoupon
|
||||
.calledWith(
|
||||
this.activeRecurlySubscription.account.account_code,
|
||||
@@ -258,7 +258,7 @@ describe('SubscriptionHandler', function() {
|
||||
done()
|
||||
})
|
||||
|
||||
it('should update the subscription', function() {
|
||||
it('should update the subscription', function () {
|
||||
this.RecurlyWrapper.updateSubscription
|
||||
.calledWith(this.subscription.recurlySubscription_id)
|
||||
.should.equal(true)
|
||||
@@ -268,9 +268,9 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('cancelSubscription', function() {
|
||||
describe('with a user without a subscription', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('cancelSubscription', function () {
|
||||
describe('with a user without a subscription', function () {
|
||||
beforeEach(function (done) {
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
@@ -280,13 +280,13 @@ describe('SubscriptionHandler', function() {
|
||||
this.SubscriptionHandler.cancelSubscription(this.user, done)
|
||||
})
|
||||
|
||||
it('should redirect to the subscription dashboard', function() {
|
||||
it('should redirect to the subscription dashboard', function () {
|
||||
this.RecurlyWrapper.cancelSubscription.called.should.equal(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a user with a subscription', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('with a user with a subscription', function () {
|
||||
beforeEach(function (done) {
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
@@ -296,7 +296,7 @@ describe('SubscriptionHandler', function() {
|
||||
this.SubscriptionHandler.cancelSubscription(this.user, done)
|
||||
})
|
||||
|
||||
it('should cancel the subscription', function() {
|
||||
it('should cancel the subscription', function () {
|
||||
this.RecurlyWrapper.cancelSubscription.called.should.equal(true)
|
||||
this.RecurlyWrapper.cancelSubscription
|
||||
.calledWith(this.subscription.recurlySubscription_id)
|
||||
@@ -305,9 +305,9 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('reactiveRecurlySubscription', function() {
|
||||
describe('with a user without a subscription', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('reactiveRecurlySubscription', function () {
|
||||
describe('with a user without a subscription', function () {
|
||||
beforeEach(function (done) {
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
@@ -317,17 +317,17 @@ describe('SubscriptionHandler', function() {
|
||||
this.SubscriptionHandler.reactivateSubscription(this.user, done)
|
||||
})
|
||||
|
||||
it('should redirect to the subscription dashboard', function() {
|
||||
it('should redirect to the subscription dashboard', function () {
|
||||
this.RecurlyWrapper.reactivateSubscription.called.should.equal(false)
|
||||
})
|
||||
|
||||
it('should not send a notification email', function() {
|
||||
it('should not send a notification email', function () {
|
||||
sinon.assert.notCalled(this.EmailHandler.sendEmail)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a user with a subscription', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('with a user with a subscription', function () {
|
||||
beforeEach(function (done) {
|
||||
this.LimitationsManager.userHasV2Subscription.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
@@ -337,14 +337,14 @@ describe('SubscriptionHandler', function() {
|
||||
this.SubscriptionHandler.reactivateSubscription(this.user, done)
|
||||
})
|
||||
|
||||
it('should reactivate the subscription', function() {
|
||||
it('should reactivate the subscription', function () {
|
||||
this.RecurlyWrapper.reactivateSubscription.called.should.equal(true)
|
||||
this.RecurlyWrapper.reactivateSubscription
|
||||
.calledWith(this.subscription.recurlySubscription_id)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should send a notification email', function() {
|
||||
it('should send a notification email', function () {
|
||||
sinon.assert.calledWith(
|
||||
this.EmailHandler.sendEmail,
|
||||
'reactivatedSubscription'
|
||||
@@ -353,9 +353,9 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('syncSubscription', function() {
|
||||
describe('with an actionable request', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('syncSubscription', function () {
|
||||
describe('with an actionable request', function () {
|
||||
beforeEach(function (done) {
|
||||
this.user.id = this.activeRecurlySubscription.account.account_code
|
||||
|
||||
this.User.findById = (userId, projection, callback) => {
|
||||
@@ -369,18 +369,18 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should request the affected subscription from the API', function() {
|
||||
it('should request the affected subscription from the API', function () {
|
||||
this.RecurlyWrapper.getSubscription
|
||||
.calledWith(this.activeRecurlySubscription.uuid)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should request the account details of the subscription', function() {
|
||||
it('should request the account details of the subscription', function () {
|
||||
const options = this.RecurlyWrapper.getSubscription.args[0][1]
|
||||
options.includeAccount.should.equal(true)
|
||||
})
|
||||
|
||||
it('should sync the subscription to the user', function() {
|
||||
it('should sync the subscription to the user', function () {
|
||||
this.SubscriptionUpdater.syncSubscription.calledOnce.should.equal(true)
|
||||
this.SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal(
|
||||
this.activeRecurlySubscription
|
||||
@@ -392,9 +392,9 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('attemptPaypalInvoiceCollection', function() {
|
||||
describe('for credit card users', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('attemptPaypalInvoiceCollection', function () {
|
||||
describe('for credit card users', function () {
|
||||
beforeEach(function (done) {
|
||||
this.RecurlyWrapper.getBillingInfo.yields(null, {
|
||||
paypal_billing_agreement_id: null
|
||||
})
|
||||
@@ -404,20 +404,20 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('gets billing infos', function() {
|
||||
it('gets billing infos', function () {
|
||||
sinon.assert.calledWith(
|
||||
this.RecurlyWrapper.getBillingInfo,
|
||||
this.activeRecurlySubscription.account.account_code
|
||||
)
|
||||
})
|
||||
|
||||
it('skips user', function() {
|
||||
it('skips user', function () {
|
||||
sinon.assert.notCalled(this.RecurlyWrapper.getAccountPastDueInvoices)
|
||||
})
|
||||
})
|
||||
|
||||
describe('for paypal users', function() {
|
||||
beforeEach(function(done) {
|
||||
describe('for paypal users', function () {
|
||||
beforeEach(function (done) {
|
||||
this.RecurlyWrapper.getBillingInfo.yields(null, {
|
||||
paypal_billing_agreement_id: 'mock-billing-agreement'
|
||||
})
|
||||
@@ -430,14 +430,14 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('gets past due invoices', function() {
|
||||
it('gets past due invoices', function () {
|
||||
sinon.assert.calledWith(
|
||||
this.RecurlyWrapper.getAccountPastDueInvoices,
|
||||
this.activeRecurlySubscription.account.account_code
|
||||
)
|
||||
})
|
||||
|
||||
it('calls attemptInvoiceCollection', function() {
|
||||
it('calls attemptInvoiceCollection', function () {
|
||||
sinon.assert.calledWith(
|
||||
this.RecurlyWrapper.attemptInvoiceCollection,
|
||||
'mock-invoice-number'
|
||||
@@ -446,8 +446,8 @@ describe('SubscriptionHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('validateNoSubscriptionInRecurly', function() {
|
||||
beforeEach(function() {
|
||||
describe('validateNoSubscriptionInRecurly', function () {
|
||||
beforeEach(function () {
|
||||
this.subscriptions = []
|
||||
this.RecurlyWrapper.listAccountActiveSubscriptions = sinon
|
||||
.stub()
|
||||
@@ -456,8 +456,8 @@ describe('SubscriptionHandler', function() {
|
||||
this.callback = sinon.stub()
|
||||
})
|
||||
|
||||
describe('with no subscription in recurly', function() {
|
||||
beforeEach(function() {
|
||||
describe('with no subscription in recurly', function () {
|
||||
beforeEach(function () {
|
||||
this.subscriptions.push((this.subscription = { mock: 'subscription' }))
|
||||
this.SubscriptionHandler.validateNoSubscriptionInRecurly(
|
||||
this.user_id,
|
||||
@@ -465,36 +465,36 @@ describe('SubscriptionHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call RecurlyWrapper.listAccountActiveSubscriptions with the user id', function() {
|
||||
it('should call RecurlyWrapper.listAccountActiveSubscriptions with the user id', function () {
|
||||
this.RecurlyWrapper.listAccountActiveSubscriptions
|
||||
.calledWith(this.user_id)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should sync the subscription', function() {
|
||||
it('should sync the subscription', function () {
|
||||
this.SubscriptionUpdater.syncSubscription
|
||||
.calledWith(this.subscription, this.user_id)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call the callback with valid == false', function() {
|
||||
it('should call the callback with valid == false', function () {
|
||||
this.callback.calledWith(null, false).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a subscription in recurly', function() {
|
||||
beforeEach(function() {
|
||||
describe('with a subscription in recurly', function () {
|
||||
beforeEach(function () {
|
||||
this.SubscriptionHandler.validateNoSubscriptionInRecurly(
|
||||
this.user_id,
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('should not sync the subscription', function() {
|
||||
it('should not sync the subscription', function () {
|
||||
this.SubscriptionUpdater.syncSubscription.called.should.equal(false)
|
||||
})
|
||||
|
||||
it('should call the callback with valid == true', function() {
|
||||
it('should call the callback with valid == true', function () {
|
||||
this.callback.calledWith(null, true).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user