|
|
@@ -38,13 +38,20 @@ describe('FeaturesUpdater', function() {
|
|
|
'../Referal/ReferalFeatures': (this.ReferalFeatures = {}),
|
|
|
'./V1SubscriptionManager': (this.V1SubscriptionManager = {}),
|
|
|
'../Institutions/InstitutionsFeatures': (this.InstitutionsFeatures = {}),
|
|
|
- '../User/UserGetter': (this.UserGetter = {})
|
|
|
+ '../User/UserGetter': (this.UserGetter = {}),
|
|
|
+ '../../infrastructure/Modules': (this.Modules = {
|
|
|
+ hooks: { fire: sinon.stub() }
|
|
|
+ })
|
|
|
}
|
|
|
}))
|
|
|
})
|
|
|
|
|
|
describe('refreshFeatures', function() {
|
|
|
beforeEach(function() {
|
|
|
+ this.user = {
|
|
|
+ _id: this.user_id,
|
|
|
+ features: {}
|
|
|
+ }
|
|
|
this.UserFeaturesUpdater.updateFeatures = sinon.stub().yields()
|
|
|
this.FeaturesUpdater._getIndividualFeatures = sinon
|
|
|
.stub()
|
|
|
@@ -64,10 +71,9 @@ describe('FeaturesUpdater', function() {
|
|
|
this.FeaturesUpdater._mergeFeatures = sinon
|
|
|
.stub()
|
|
|
.returns({ merged: 'features' })
|
|
|
- this.UserGetter.getUser = sinon.stub().yields(null, {})
|
|
|
+ this.UserGetter.getUser = sinon.stub().yields(null, this.user)
|
|
|
return (this.callback = sinon.stub())
|
|
|
})
|
|
|
-
|
|
|
describe('normally', function() {
|
|
|
beforeEach(function() {
|
|
|
return this.FeaturesUpdater.refreshFeatures(this.user_id, this.callback)
|
|
|
@@ -148,6 +154,24 @@ describe('FeaturesUpdater', function() {
|
|
|
.should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
+ describe('when losing dropbox feature', function() {
|
|
|
+ beforeEach(function() {
|
|
|
+ this.user = {
|
|
|
+ _id: this.user_id,
|
|
|
+ features: { dropbox: true }
|
|
|
+ }
|
|
|
+ this.UserGetter.getUser = sinon.stub().yields(null, this.user)
|
|
|
+ this.FeaturesUpdater._mergeFeatures = sinon
|
|
|
+ .stub()
|
|
|
+ .returns({ dropbox: false })
|
|
|
+ return this.FeaturesUpdater.refreshFeatures(this.user_id, this.callback)
|
|
|
+ })
|
|
|
+ it('should fire module hook to unlink dropbox', function() {
|
|
|
+ this.Modules.hooks.fire
|
|
|
+ .calledWith('removeDropbox', this.user._id)
|
|
|
+ .should.equal(true)
|
|
|
+ })
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('_mergeFeatures', function() {
|