mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 01:31:19 +00:00
Update remaining unit tests
This commit is contained in:
parent
28f51cd4b4
commit
6e2ec2f982
2 changed files with 13 additions and 10 deletions
|
@ -52,8 +52,7 @@ describe "SubscriptionHandler", ->
|
|||
startFreeTrial: sinon.stub().callsArgWith(1)
|
||||
|
||||
@LimitationsManager =
|
||||
userHasSubscription: sinon.stub()
|
||||
userHasSubscriptionOrFreeTrial: sinon.stub()
|
||||
userHasV2Subscription: sinon.stub()
|
||||
|
||||
@EmailHandler =
|
||||
sendEmail:sinon.stub()
|
||||
|
@ -110,7 +109,7 @@ describe "SubscriptionHandler", ->
|
|||
describe "with a valid plan code", ->
|
||||
beforeEach (done) ->
|
||||
@plan_code = "collaborator"
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
|
||||
@SubscriptionHandler.updateSubscription(@user, @plan_code, null, done)
|
||||
|
||||
it "should update the subscription", ->
|
||||
|
@ -129,7 +128,7 @@ describe "SubscriptionHandler", ->
|
|||
|
||||
describe "with a user without a subscription", ->
|
||||
beforeEach (done) ->
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false)
|
||||
@SubscriptionHandler.updateSubscription(@user, @plan_code, null, done)
|
||||
|
||||
it "should redirect to the subscription dashboard", ->
|
||||
|
@ -140,7 +139,7 @@ describe "SubscriptionHandler", ->
|
|||
beforeEach (done) ->
|
||||
@plan_code = "collaborator"
|
||||
@coupon_code = "1231312"
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
|
||||
@SubscriptionHandler.updateSubscription(@user, @plan_code, @coupon_code, done)
|
||||
|
||||
it "should get the users account", ->
|
||||
|
@ -158,7 +157,7 @@ describe "SubscriptionHandler", ->
|
|||
describe "cancelSubscription", ->
|
||||
describe "with a user without a subscription", ->
|
||||
beforeEach (done) ->
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false, @subscription)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false, @subscription)
|
||||
@SubscriptionHandler.cancelSubscription @user, done
|
||||
|
||||
|
||||
|
@ -167,7 +166,7 @@ describe "SubscriptionHandler", ->
|
|||
|
||||
describe "with a user with a subscription", ->
|
||||
beforeEach (done) ->
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
|
||||
@SubscriptionHandler.cancelSubscription @user, done
|
||||
|
||||
it "should cancel the subscription", ->
|
||||
|
@ -180,7 +179,7 @@ describe "SubscriptionHandler", ->
|
|||
describe "reactiveRecurlySubscription", ->
|
||||
describe "with a user without a subscription", ->
|
||||
beforeEach (done) ->
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false, @subscription)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false, @subscription)
|
||||
@SubscriptionHandler.reactivateSubscription @user, done
|
||||
|
||||
it "should redirect to the subscription dashboard", ->
|
||||
|
@ -188,7 +187,7 @@ describe "SubscriptionHandler", ->
|
|||
|
||||
describe "with a user with a subscription", ->
|
||||
beforeEach (done) ->
|
||||
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription)
|
||||
@LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
|
||||
@SubscriptionHandler.reactivateSubscription @user, done
|
||||
|
||||
it "should reactivate the subscription", ->
|
||||
|
|
|
@ -42,6 +42,7 @@ describe 'SubscriptionViewModelBuilder', ->
|
|||
"./SubscriptionLocator": @SubscriptionLocator = {}
|
||||
"./SubscriptionFormatters": @SubscriptionFormatters
|
||||
"./LimitationsManager": {}
|
||||
"./V1SubscriptionManager": @V1SubscriptionManager = {}
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
warn:->
|
||||
|
@ -50,13 +51,15 @@ describe 'SubscriptionViewModelBuilder', ->
|
|||
@PlansLocator.findLocalPlanInSettings = sinon.stub().returns(@plan)
|
||||
@SubscriptionLocator.getUsersSubscription = sinon.stub().callsArgWith(1, null, mockSubscription)
|
||||
@SubscriptionLocator.getMemberSubscriptions = sinon.stub().callsArgWith(1, null, null)
|
||||
@V1SubscriptionManager.getSubscriptionsFromV1 = sinon.stub().yields(null, @mockV1Sub = ['mock-v1-subs'])
|
||||
|
||||
it 'builds the user view model', ->
|
||||
callback = (error, subscription, memberSubscriptions, billingDetailsLink) =>
|
||||
callback = (error, subscription, memberSubscriptions, billingDetailsLink, v1Sub) =>
|
||||
@error = error
|
||||
@subscription = subscription
|
||||
@memberSubscriptions = memberSubscriptions
|
||||
@billingDetailsLink = billingDetailsLink
|
||||
@v1Sub = v1Sub
|
||||
|
||||
@builder.buildUsersSubscriptionViewModel(@user, callback)
|
||||
|
||||
|
@ -64,3 +67,4 @@ describe 'SubscriptionViewModelBuilder', ->
|
|||
@subscription.nextPaymentDueAt.should.eq 'Formatted date'
|
||||
@subscription.price.should.eq 'Formatted price'
|
||||
@billingDetailsLink.should.eq "https://example.com.recurly.com/account/billing_info/edit?ht=hosted_login_token"
|
||||
@v1Sub.should.deep.equal @mockV1Sub
|
Loading…
Reference in a new issue