mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-02 13:31:54 +00:00
test untrackSession
This commit is contained in:
parent
2ae2e6ed4f
commit
dfcb47fb5c
1 changed files with 94 additions and 0 deletions
|
@ -148,3 +148,97 @@ describe 'UserSessionsManager', ->
|
|||
@call (err) =>
|
||||
@_checkSessions.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
describe 'untrackSession', ->
|
||||
|
||||
beforeEach ->
|
||||
@call = (callback) =>
|
||||
@UserSessionsManager.untrackSession @user, @sessionId, callback
|
||||
@rclient.exec.callsArgWith(0, null)
|
||||
@_checkSessions = sinon.stub(@UserSessionsManager, '_checkSessions').returns(null)
|
||||
|
||||
afterEach ->
|
||||
@_checkSessions.restore()
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.not.be.instanceof Error
|
||||
done()
|
||||
|
||||
it 'should call the appropriate redis methods', (done) ->
|
||||
@call (err) =>
|
||||
@rclient.multi.callCount.should.equal 1
|
||||
@rclient.srem.callCount.should.equal 1
|
||||
@rclient.expire.callCount.should.equal 1
|
||||
@rclient.exec.callCount.should.equal 1
|
||||
done()
|
||||
|
||||
it 'should call _checkSessions', (done) ->
|
||||
@call (err) =>
|
||||
@_checkSessions.callCount.should.equal 1
|
||||
done()
|
||||
|
||||
describe 'when rclient produces an error', ->
|
||||
|
||||
beforeEach ->
|
||||
@rclient.exec.callsArgWith(0, new Error('woops'))
|
||||
|
||||
it 'should produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
|
||||
it 'should not call _checkSessions', (done) ->
|
||||
@call (err) =>
|
||||
@_checkSessions.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
describe 'when no user is supplied', ->
|
||||
|
||||
beforeEach ->
|
||||
@call = (callback) =>
|
||||
@UserSessionsManager.untrackSession null, @sessionId, callback
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.not.be.instanceof Error
|
||||
expect(err).to.equal null
|
||||
done()
|
||||
|
||||
it 'should not call the appropriate redis methods', (done) ->
|
||||
@call (err) =>
|
||||
@rclient.multi.callCount.should.equal 0
|
||||
@rclient.srem.callCount.should.equal 0
|
||||
@rclient.expire.callCount.should.equal 0
|
||||
@rclient.exec.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
it 'should not call _checkSessions', (done) ->
|
||||
@call (err) =>
|
||||
@_checkSessions.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
describe 'when no sessionId is supplied', ->
|
||||
|
||||
beforeEach ->
|
||||
@call = (callback) =>
|
||||
@UserSessionsManager.untrackSession @user, null, callback
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.not.be.instanceof Error
|
||||
expect(err).to.equal null
|
||||
done()
|
||||
|
||||
it 'should not call the appropriate redis methods', (done) ->
|
||||
@call (err) =>
|
||||
@rclient.multi.callCount.should.equal 0
|
||||
@rclient.srem.callCount.should.equal 0
|
||||
@rclient.expire.callCount.should.equal 0
|
||||
@rclient.exec.callCount.should.equal 0
|
||||
done()
|
||||
|
||||
it 'should not call _checkSessions', (done) ->
|
||||
@call (err) =>
|
||||
@_checkSessions.callCount.should.equal 0
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue