|
|
@@ -607,79 +607,6 @@ describe('UserEmailsController', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('resendConfirmation', function () {
|
|
|
- beforeEach(function () {
|
|
|
- this.EmailHelper.parseEmail.returnsArg(0)
|
|
|
- this.UserGetter.promises.getUserByAnyEmail.resolves({
|
|
|
- _id: this.user._id,
|
|
|
- })
|
|
|
- this.req = {
|
|
|
- body: {},
|
|
|
- }
|
|
|
- this.res = {
|
|
|
- sendStatus: sinon.stub(),
|
|
|
- }
|
|
|
- this.next = sinon.stub()
|
|
|
- this.UserEmailsConfirmationHandler.sendConfirmationEmail = sinon
|
|
|
- .stub()
|
|
|
- .yields()
|
|
|
- })
|
|
|
-
|
|
|
- it('should send the email', async function () {
|
|
|
- this.req = {
|
|
|
- body: {
|
|
|
- email: 'test@example.com',
|
|
|
- },
|
|
|
- }
|
|
|
- await this.UserEmailsController.sendReconfirmation(
|
|
|
- this.req,
|
|
|
- this.res,
|
|
|
- this.next
|
|
|
- )
|
|
|
- expect(
|
|
|
- this.UserEmailsConfirmationHandler.promises.sendReconfirmationEmail
|
|
|
- ).to.have.been.calledOnce
|
|
|
- })
|
|
|
-
|
|
|
- it('should return 422 if email not valid', function (done) {
|
|
|
- this.req = {
|
|
|
- body: {},
|
|
|
- }
|
|
|
- this.UserEmailsController.resendConfirmation(
|
|
|
- this.req,
|
|
|
- this.res,
|
|
|
- this.next
|
|
|
- )
|
|
|
- expect(this.UserEmailsConfirmationHandler.sendConfirmationEmail).to.not
|
|
|
- .have.been.called
|
|
|
- expect(this.res.sendStatus.lastCall.args[0]).to.equal(422)
|
|
|
- done()
|
|
|
- })
|
|
|
-
|
|
|
- describe('email on another user account', function () {
|
|
|
- beforeEach(function () {
|
|
|
- this.UserGetter.promises.getUserByAnyEmail.resolves({
|
|
|
- _id: 'another-user-id',
|
|
|
- })
|
|
|
- })
|
|
|
- it('should return 422', async function () {
|
|
|
- this.req = {
|
|
|
- body: {
|
|
|
- email: 'test@example.com',
|
|
|
- },
|
|
|
- }
|
|
|
- await this.UserEmailsController.resendConfirmation(
|
|
|
- this.req,
|
|
|
- this.res,
|
|
|
- this.next
|
|
|
- )
|
|
|
- expect(this.UserEmailsConfirmationHandler.sendConfirmationEmail).to.not
|
|
|
- .have.been.called
|
|
|
- expect(this.res.sendStatus.lastCall.args[0]).to.equal(422)
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
describe('sendReconfirmation', function () {
|
|
|
beforeEach(function () {
|
|
|
this.res.sendStatus = sinon.stub()
|