Fix unit tests

This commit is contained in:
Shane Kilkelly 2016-11-08 16:00:18 +00:00
parent bfa0e7cf89
commit a373868862
2 changed files with 5 additions and 5 deletions

View file

@ -92,7 +92,7 @@ describe "AuthenticationController", ->
@req.login = sinon.stub().callsArgWith(1, null) @req.login = sinon.stub().callsArgWith(1, null)
@res.json = sinon.stub() @res.json = sinon.stub()
@req.session = @session = {passport: {user: @user}} @req.session = @session = {passport: {user: @user}}
@req.session.destroy = sinon.stub() @req.session.destroy = sinon.stub().callsArgWith(0, null)
@req.session.save = sinon.stub().callsArgWith(0, null) @req.session.save = sinon.stub().callsArgWith(0, null)
@req.sessionStore = {generate: sinon.stub()} @req.sessionStore = {generate: sinon.stub()}
@passport.authenticate.callsArgWith(1, null, @user, @info) @passport.authenticate.callsArgWith(1, null, @user, @info)
@ -164,7 +164,7 @@ describe "AuthenticationController", ->
@req.session = @session = {passport: {user: @user}} @req.session = @session = {passport: {user: @user}}
@req.session = @req.session =
passport: {user: {_id: "one"}} passport: {user: {_id: "one"}}
@req.session.destroy = sinon.stub() @req.session.destroy = sinon.stub().callsArgWith(0, null)
@req.session.save = sinon.stub().callsArgWith(0, null) @req.session.save = sinon.stub().callsArgWith(0, null)
@req.sessionStore = {generate: sinon.stub()} @req.sessionStore = {generate: sinon.stub()}
@UserSessionsManager.trackSession = sinon.stub() @UserSessionsManager.trackSession = sinon.stub()

View file

@ -33,7 +33,7 @@ describe 'UserSessionsManager', ->
@rclient.exec.callsArgWith(0, null) @rclient.exec.callsArgWith(0, null)
@redis = @redis =
createClient: () => @rclient client: () => @rclient
@logger = @logger =
err: sinon.stub() err: sinon.stub()
error: sinon.stub() error: sinon.stub()
@ -42,15 +42,15 @@ describe 'UserSessionsManager', ->
redis: redis:
web: {} web: {}
@UserSessionsManager = SandboxedModule.require modulePath, requires: @UserSessionsManager = SandboxedModule.require modulePath, requires:
"redis-sharelatex": @redis
"logger-sharelatex": @logger "logger-sharelatex": @logger
"settings-sharelatex": @settings "settings-sharelatex": @settings
'./UserSessionsRedis': @redis
describe '_sessionSetKey', -> describe '_sessionSetKey', ->
it 'should build the correct key', -> it 'should build the correct key', ->
result = @UserSessionsManager._sessionSetKey(@user) result = @UserSessionsManager._sessionSetKey(@user)
result.should.equal 'UserSessions:abcd' result.should.equal 'UserSessions:{abcd}'
describe '_sessionKey', -> describe '_sessionKey', ->