Update remaining unit tests

This commit is contained in:
James Allen 2018-06-07 17:16:21 +01:00
parent 28f51cd4b4
commit 6e2ec2f982
2 changed files with 13 additions and 10 deletions

View file

@ -52,8 +52,7 @@ describe "SubscriptionHandler", ->
startFreeTrial: sinon.stub().callsArgWith(1) startFreeTrial: sinon.stub().callsArgWith(1)
@LimitationsManager = @LimitationsManager =
userHasSubscription: sinon.stub() userHasV2Subscription: sinon.stub()
userHasSubscriptionOrFreeTrial: sinon.stub()
@EmailHandler = @EmailHandler =
sendEmail:sinon.stub() sendEmail:sinon.stub()
@ -110,7 +109,7 @@ describe "SubscriptionHandler", ->
describe "with a valid plan code", -> describe "with a valid plan code", ->
beforeEach (done) -> beforeEach (done) ->
@plan_code = "collaborator" @plan_code = "collaborator"
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription) @LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
@SubscriptionHandler.updateSubscription(@user, @plan_code, null, done) @SubscriptionHandler.updateSubscription(@user, @plan_code, null, done)
it "should update the subscription", -> it "should update the subscription", ->
@ -129,7 +128,7 @@ describe "SubscriptionHandler", ->
describe "with a user without a subscription", -> describe "with a user without a subscription", ->
beforeEach (done) -> beforeEach (done) ->
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false) @LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false)
@SubscriptionHandler.updateSubscription(@user, @plan_code, null, done) @SubscriptionHandler.updateSubscription(@user, @plan_code, null, done)
it "should redirect to the subscription dashboard", -> it "should redirect to the subscription dashboard", ->
@ -140,7 +139,7 @@ describe "SubscriptionHandler", ->
beforeEach (done) -> beforeEach (done) ->
@plan_code = "collaborator" @plan_code = "collaborator"
@coupon_code = "1231312" @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) @SubscriptionHandler.updateSubscription(@user, @plan_code, @coupon_code, done)
it "should get the users account", -> it "should get the users account", ->
@ -158,7 +157,7 @@ describe "SubscriptionHandler", ->
describe "cancelSubscription", -> describe "cancelSubscription", ->
describe "with a user without a subscription", -> describe "with a user without a subscription", ->
beforeEach (done) -> beforeEach (done) ->
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false, @subscription) @LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false, @subscription)
@SubscriptionHandler.cancelSubscription @user, done @SubscriptionHandler.cancelSubscription @user, done
@ -167,7 +166,7 @@ describe "SubscriptionHandler", ->
describe "with a user with a subscription", -> describe "with a user with a subscription", ->
beforeEach (done) -> beforeEach (done) ->
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription) @LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
@SubscriptionHandler.cancelSubscription @user, done @SubscriptionHandler.cancelSubscription @user, done
it "should cancel the subscription", -> it "should cancel the subscription", ->
@ -180,7 +179,7 @@ describe "SubscriptionHandler", ->
describe "reactiveRecurlySubscription", -> describe "reactiveRecurlySubscription", ->
describe "with a user without a subscription", -> describe "with a user without a subscription", ->
beforeEach (done) -> beforeEach (done) ->
@LimitationsManager.userHasSubscription.callsArgWith(1, null, false, @subscription) @LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false, @subscription)
@SubscriptionHandler.reactivateSubscription @user, done @SubscriptionHandler.reactivateSubscription @user, done
it "should redirect to the subscription dashboard", -> it "should redirect to the subscription dashboard", ->
@ -188,7 +187,7 @@ describe "SubscriptionHandler", ->
describe "with a user with a subscription", -> describe "with a user with a subscription", ->
beforeEach (done) -> beforeEach (done) ->
@LimitationsManager.userHasSubscription.callsArgWith(1, null, true, @subscription) @LimitationsManager.userHasV2Subscription.callsArgWith(1, null, true, @subscription)
@SubscriptionHandler.reactivateSubscription @user, done @SubscriptionHandler.reactivateSubscription @user, done
it "should reactivate the subscription", -> it "should reactivate the subscription", ->

View file

@ -42,6 +42,7 @@ describe 'SubscriptionViewModelBuilder', ->
"./SubscriptionLocator": @SubscriptionLocator = {} "./SubscriptionLocator": @SubscriptionLocator = {}
"./SubscriptionFormatters": @SubscriptionFormatters "./SubscriptionFormatters": @SubscriptionFormatters
"./LimitationsManager": {} "./LimitationsManager": {}
"./V1SubscriptionManager": @V1SubscriptionManager = {}
"logger-sharelatex": "logger-sharelatex":
log:-> log:->
warn:-> warn:->
@ -50,13 +51,15 @@ describe 'SubscriptionViewModelBuilder', ->
@PlansLocator.findLocalPlanInSettings = sinon.stub().returns(@plan) @PlansLocator.findLocalPlanInSettings = sinon.stub().returns(@plan)
@SubscriptionLocator.getUsersSubscription = sinon.stub().callsArgWith(1, null, mockSubscription) @SubscriptionLocator.getUsersSubscription = sinon.stub().callsArgWith(1, null, mockSubscription)
@SubscriptionLocator.getMemberSubscriptions = sinon.stub().callsArgWith(1, null, null) @SubscriptionLocator.getMemberSubscriptions = sinon.stub().callsArgWith(1, null, null)
@V1SubscriptionManager.getSubscriptionsFromV1 = sinon.stub().yields(null, @mockV1Sub = ['mock-v1-subs'])
it 'builds the user view model', -> it 'builds the user view model', ->
callback = (error, subscription, memberSubscriptions, billingDetailsLink) => callback = (error, subscription, memberSubscriptions, billingDetailsLink, v1Sub) =>
@error = error @error = error
@subscription = subscription @subscription = subscription
@memberSubscriptions = memberSubscriptions @memberSubscriptions = memberSubscriptions
@billingDetailsLink = billingDetailsLink @billingDetailsLink = billingDetailsLink
@v1Sub = v1Sub
@builder.buildUsersSubscriptionViewModel(@user, callback) @builder.buildUsersSubscriptionViewModel(@user, callback)
@ -64,3 +67,4 @@ describe 'SubscriptionViewModelBuilder', ->
@subscription.nextPaymentDueAt.should.eq 'Formatted date' @subscription.nextPaymentDueAt.should.eq 'Formatted date'
@subscription.price.should.eq 'Formatted price' @subscription.price.should.eq 'Formatted price'
@billingDetailsLink.should.eq "https://example.com.recurly.com/account/billing_info/edit?ht=hosted_login_token" @billingDetailsLink.should.eq "https://example.com.recurly.com/account/billing_info/edit?ht=hosted_login_token"
@v1Sub.should.deep.equal @mockV1Sub