mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Test getInviteCount
This commit is contained in:
parent
3a3688d3d0
commit
5f8952450e
1 changed files with 29 additions and 0 deletions
|
@ -20,6 +20,7 @@ describe "CollaboratorsInviteHandler", ->
|
|||
@findOne: sinon.stub()
|
||||
@find: sinon.stub()
|
||||
@remove: sinon.stub()
|
||||
@count: sinon.stub()
|
||||
@Crypto = Crypto
|
||||
@CollaboratorsInviteHandler = SandboxedModule.require modulePath, requires:
|
||||
'settings-sharelatex': @settings = {}
|
||||
|
@ -48,6 +49,34 @@ describe "CollaboratorsInviteHandler", ->
|
|||
privileges: @privileges
|
||||
createdAt: new Date()
|
||||
|
||||
describe 'getInviteCount', ->
|
||||
|
||||
beforeEach ->
|
||||
@ProjectInvite.count.callsArgWith(1, null, 2)
|
||||
@call = (callback) =>
|
||||
@CollaboratorsInviteHandler.getInviteCount @projectId, callback
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@call (err, invites) =>
|
||||
expect(err).to.not.be.instanceof Error
|
||||
expect(err).to.be.oneOf [null, undefined]
|
||||
done()
|
||||
|
||||
it 'should produce the count of documents', (done) ->
|
||||
@call (err, count) =>
|
||||
expect(count).to.equal 2
|
||||
done()
|
||||
|
||||
describe 'when model.count produces an error', ->
|
||||
|
||||
beforeEach ->
|
||||
@ProjectInvite.count.callsArgWith(1, new Error('woops'))
|
||||
|
||||
it 'should produce an error', (done) ->
|
||||
@call (err, count) =>
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
|
||||
describe 'getAllInvites', ->
|
||||
|
||||
beforeEach ->
|
||||
|
|
Loading…
Reference in a new issue