mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Test revokeInvite
This commit is contained in:
+36
-1
@@ -17,7 +17,8 @@ describe "CollaboratorsInviteHandler", ->
|
||||
this[k] = v
|
||||
this
|
||||
save: sinon.stub()
|
||||
findOne: sinon.stub()
|
||||
@findOne: sinon.stub()
|
||||
@remove: sinon.stub()
|
||||
@Project = {}
|
||||
@Crypto = Crypto
|
||||
@CollaboratorsInviteHandler = SandboxedModule.require modulePath, requires:
|
||||
@@ -33,6 +34,7 @@ describe "CollaboratorsInviteHandler", ->
|
||||
@sendingUserId = ObjectId()
|
||||
@email = "user@example.com"
|
||||
@userId = ObjectId()
|
||||
@inviteId = ObjectId()
|
||||
@privileges = "readAndWrite"
|
||||
|
||||
describe 'inviteToProject', ->
|
||||
@@ -89,3 +91,36 @@ describe "CollaboratorsInviteHandler", ->
|
||||
@call (err, invite) =>
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
|
||||
describe 'revokeInvite', ->
|
||||
|
||||
beforeEach ->
|
||||
@ProjectInvite.remove.callsArgWith(1, null)
|
||||
@CollaboratorsEmailHandler.notifyUserOfProjectInvite = sinon.stub()
|
||||
@call = (callback) =>
|
||||
@CollaboratorsInviteHandler.revokeInvite @projectId, @inviteId, callback
|
||||
|
||||
describe 'when all goes well', ->
|
||||
|
||||
beforeEach ->
|
||||
|
||||
it 'should not produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.not.be.instanceof Error
|
||||
done()
|
||||
|
||||
it 'should call ProjectInvite.remove', (done) ->
|
||||
@call (err) =>
|
||||
@ProjectInvite.remove.callCount.should.equal 1
|
||||
@ProjectInvite.remove.calledWith({projectId: @projectId, _id: @inviteId}).should.equal true
|
||||
done()
|
||||
|
||||
describe 'when remove produces an error', ->
|
||||
|
||||
beforeEach ->
|
||||
@ProjectInvite.remove.callsArgWith(1, new Error('woops'))
|
||||
|
||||
it 'should produce an error', (done) ->
|
||||
@call (err) =>
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
|
||||
Reference in New Issue
Block a user