mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-12 16:43:02 +00:00
Fix ReferalFeatures tests
This commit is contained in:
parent
7e5ababe66
commit
8b8742d60f
1 changed files with 11 additions and 12 deletions
|
@ -8,7 +8,7 @@ describe 'ReferalFeatures', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@ReferalFeatures = SandboxedModule.require modulePath, requires:
|
@ReferalFeatures = SandboxedModule.require modulePath, requires:
|
||||||
'../../models/User': User: @User = {}
|
'../User/UserGetter': @UserGetter = {}
|
||||||
"settings-sharelatex": @Settings = {}
|
"settings-sharelatex": @Settings = {}
|
||||||
'logger-sharelatex':
|
'logger-sharelatex':
|
||||||
log:->
|
log:->
|
||||||
|
@ -32,12 +32,12 @@ describe 'ReferalFeatures', ->
|
||||||
features:{collaborators:1, dropbox:false, versioning:false}
|
features:{collaborators:1, dropbox:false, versioning:false}
|
||||||
}
|
}
|
||||||
|
|
||||||
@User.findOne = sinon.stub().callsArgWith 1, null, stubbedUser
|
@UserGetter.getUserOrUserStubById = sinon.stub().yields null, stubbedUser
|
||||||
@ReferalFeatures.getBonusFeatures @user_id, @callback
|
@ReferalFeatures.getBonusFeatures @user_id, @callback
|
||||||
|
|
||||||
it "should get the users number of refered user", ->
|
it "should get the users number of refered user", ->
|
||||||
@User.findOne
|
@UserGetter.getUserOrUserStubById
|
||||||
.calledWith(_id: @user_id)
|
.calledWith(@user_id, { _id: 1 })
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should call the callback with the features", ->
|
it "should call the callback with the features", ->
|
||||||
|
@ -51,15 +51,14 @@ describe 'ReferalFeatures', ->
|
||||||
collaborators: 3
|
collaborators: 3
|
||||||
dropbox: false
|
dropbox: false
|
||||||
versioning: false
|
versioning: false
|
||||||
@User.findOne = sinon.stub().callsArgWith 1, null, { refered_user_count: @refered_user_count }
|
@UserGetter.getUserOrUserStubById =
|
||||||
|
sinon.stub().yields null, { refered_user_count: @refered_user_count }
|
||||||
@ReferalFeatures.getBonusFeatures @user_id, @callback
|
@ReferalFeatures.getBonusFeatures @user_id, @callback
|
||||||
|
|
||||||
it "should get the users number of refered user", ->
|
it "should get the users number of refered user", ->
|
||||||
@User.findOne
|
@UserGetter.getUserOrUserStubById
|
||||||
.calledWith(_id: @user_id)
|
.calledWith(@user_id, { _id: 1 })
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should call the callback with no features", ->
|
it "should call the callback with no features", ->
|
||||||
@callback.calledWith(null, {}).should.equal true
|
@callback.calledWith(null, {}).should.equal true
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue