mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Fix unit tests for SubscriptionUpdater
This commit is contained in:
parent
e7d8848a6a
commit
44c289d8dd
1 changed files with 15 additions and 0 deletions
|
@ -57,6 +57,7 @@ describe "SubscriptionUpdater", ->
|
||||||
|
|
||||||
@ReferalAllocator = assignBonus:sinon.stub().callsArgWith(1)
|
@ReferalAllocator = assignBonus:sinon.stub().callsArgWith(1)
|
||||||
@ReferalAllocator.cock = true
|
@ReferalAllocator.cock = true
|
||||||
|
@Modules = {hooks: {fire: sinon.stub().callsArgWith(2, null, null)}}
|
||||||
@SubscriptionUpdater = SandboxedModule.require modulePath, requires:
|
@SubscriptionUpdater = SandboxedModule.require modulePath, requires:
|
||||||
'../../models/Subscription': Subscription:@SubscriptionModel
|
'../../models/Subscription': Subscription:@SubscriptionModel
|
||||||
'./UserFeaturesUpdater': @UserFeaturesUpdater
|
'./UserFeaturesUpdater': @UserFeaturesUpdater
|
||||||
|
@ -65,6 +66,7 @@ describe "SubscriptionUpdater", ->
|
||||||
"logger-sharelatex": log:->
|
"logger-sharelatex": log:->
|
||||||
'settings-sharelatex': @Settings
|
'settings-sharelatex': @Settings
|
||||||
"../Referal/ReferalAllocator" : @ReferalAllocator
|
"../Referal/ReferalAllocator" : @ReferalAllocator
|
||||||
|
'../../infrastructure/Modules': @Modules
|
||||||
|
|
||||||
|
|
||||||
describe "syncSubscription", ->
|
describe "syncSubscription", ->
|
||||||
|
@ -204,10 +206,22 @@ describe "SubscriptionUpdater", ->
|
||||||
assert.equal args[1], @groupSubscription.planCode
|
assert.equal args[1], @groupSubscription.planCode
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
it "should call updateFeatures with the overleaf subscription if set", (done)->
|
||||||
|
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null)
|
||||||
|
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null, null)
|
||||||
|
@Modules.hooks.fire = sinon.stub().callsArgWith(2, null, 'ol_pro')
|
||||||
|
|
||||||
|
@SubscriptionUpdater._setUsersMinimumFeatures @adminUser._id, (err)=>
|
||||||
|
args = @UserFeaturesUpdater.updateFeatures.args[0]
|
||||||
|
assert.equal args[0], @adminUser._id
|
||||||
|
assert.equal args[1], 'ol_pro'
|
||||||
|
done()
|
||||||
|
|
||||||
it "should call not call updateFeatures with users subscription if the subscription plan code is the default one (downgraded)", (done)->
|
it "should call not call updateFeatures with users subscription if the subscription plan code is the default one (downgraded)", (done)->
|
||||||
@subscription.planCode = @Settings.defaultPlanCode
|
@subscription.planCode = @Settings.defaultPlanCode
|
||||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, @subscription)
|
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, @subscription)
|
||||||
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null, @groupSubscription)
|
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null, @groupSubscription)
|
||||||
|
@Modules.hooks.fire = sinon.stub().callsArgWith(2, null, null)
|
||||||
@SubscriptionUpdater._setUsersMinimumFeatures @adminuser_id, (err)=>
|
@SubscriptionUpdater._setUsersMinimumFeatures @adminuser_id, (err)=>
|
||||||
args = @UserFeaturesUpdater.updateFeatures.args[0]
|
args = @UserFeaturesUpdater.updateFeatures.args[0]
|
||||||
assert.equal args[0], @adminUser._id
|
assert.equal args[0], @adminUser._id
|
||||||
|
@ -218,6 +232,7 @@ describe "SubscriptionUpdater", ->
|
||||||
it "should call updateFeatures with default if there are no subscriptions for user", (done)->
|
it "should call updateFeatures with default if there are no subscriptions for user", (done)->
|
||||||
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null)
|
@SubscriptionLocator.getUsersSubscription.callsArgWith(1, null)
|
||||||
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null)
|
@SubscriptionLocator.getGroupSubscriptionMemberOf.callsArgWith(1, null)
|
||||||
|
@Modules.hooks.fire = sinon.stub().callsArgWith(2, null, null)
|
||||||
@SubscriptionUpdater._setUsersMinimumFeatures @adminuser_id, (err)=>
|
@SubscriptionUpdater._setUsersMinimumFeatures @adminuser_id, (err)=>
|
||||||
args = @UserFeaturesUpdater.updateFeatures.args[0]
|
args = @UserFeaturesUpdater.updateFeatures.args[0]
|
||||||
assert.equal args[0], @adminUser._id
|
assert.equal args[0], @adminUser._id
|
||||||
|
|
Loading…
Reference in a new issue