mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 05:41:33 +02:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -22,8 +22,8 @@ const { expect } = require('chai')
|
||||
const Errors = require('../../../../app/src/Features/Errors/Errors')
|
||||
const EmailHelper = require('../../../../app/src/Features/Helpers/EmailHelper')
|
||||
|
||||
describe('UserEmailsConfirmationHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('UserEmailsConfirmationHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.UserEmailsConfirmationHandler = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'settings-sharelatex': (this.settings = {
|
||||
@@ -48,16 +48,16 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
return (this.callback = sinon.stub())
|
||||
})
|
||||
|
||||
describe('sendConfirmationEmail', function() {
|
||||
beforeEach(function() {
|
||||
describe('sendConfirmationEmail', function () {
|
||||
beforeEach(function () {
|
||||
this.OneTimeTokenHandler.getNewToken = sinon
|
||||
.stub()
|
||||
.yields(null, (this.token = 'new-token'))
|
||||
return (this.EmailHandler.sendEmail = sinon.stub().yields())
|
||||
})
|
||||
|
||||
describe('successfully', function() {
|
||||
beforeEach(function() {
|
||||
describe('successfully', function () {
|
||||
beforeEach(function () {
|
||||
return this.UserEmailsConfirmationHandler.sendConfirmationEmail(
|
||||
this.user_id,
|
||||
this.email,
|
||||
@@ -65,7 +65,7 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should generate a token for the user which references their id and email', function() {
|
||||
it('should generate a token for the user which references their id and email', function () {
|
||||
return this.OneTimeTokenHandler.getNewToken
|
||||
.calledWith(
|
||||
'email_confirmation',
|
||||
@@ -75,7 +75,7 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should send an email to the user', function() {
|
||||
it('should send an email to the user', function () {
|
||||
return this.EmailHandler.sendEmail
|
||||
.calledWith('confirmEmail', {
|
||||
to: this.email,
|
||||
@@ -86,13 +86,13 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call the callback', function() {
|
||||
it('should call the callback', function () {
|
||||
return this.callback.called.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid email', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid email', function () {
|
||||
beforeEach(function () {
|
||||
return this.UserEmailsConfirmationHandler.sendConfirmationEmail(
|
||||
this.user_id,
|
||||
'!"£$%^&*()',
|
||||
@@ -100,15 +100,15 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should return an error', function() {
|
||||
it('should return an error', function () {
|
||||
return this.callback
|
||||
.calledWith(sinon.match.instanceOf(Error))
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('a custom template', function() {
|
||||
beforeEach(function() {
|
||||
describe('a custom template', function () {
|
||||
beforeEach(function () {
|
||||
return this.UserEmailsConfirmationHandler.sendConfirmationEmail(
|
||||
this.user_id,
|
||||
this.email,
|
||||
@@ -117,7 +117,7 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send an email with the given template', function() {
|
||||
it('should send an email with the given template', function () {
|
||||
return this.EmailHandler.sendEmail
|
||||
.calledWith('myCustomTemplate')
|
||||
.should.equal(true)
|
||||
@@ -125,41 +125,41 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirmEmailFromToken', function() {
|
||||
beforeEach(function() {
|
||||
describe('confirmEmailFromToken', function () {
|
||||
beforeEach(function () {
|
||||
this.OneTimeTokenHandler.getValueFromTokenAndExpire = sinon
|
||||
.stub()
|
||||
.yields(null, { user_id: this.user_id, email: this.email })
|
||||
return (this.UserUpdater.confirmEmail = sinon.stub().yields())
|
||||
})
|
||||
|
||||
describe('successfully', function() {
|
||||
beforeEach(function() {
|
||||
describe('successfully', function () {
|
||||
beforeEach(function () {
|
||||
return this.UserEmailsConfirmationHandler.confirmEmailFromToken(
|
||||
(this.token = 'mock-token'),
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('should call getValueFromTokenAndExpire', function() {
|
||||
it('should call getValueFromTokenAndExpire', function () {
|
||||
return this.OneTimeTokenHandler.getValueFromTokenAndExpire
|
||||
.calledWith('email_confirmation', this.token)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should confirm the email of the user_id', function() {
|
||||
it('should confirm the email of the user_id', function () {
|
||||
return this.UserUpdater.confirmEmail
|
||||
.calledWith(this.user_id, this.email)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call the callback', function() {
|
||||
it('should call the callback', function () {
|
||||
return this.callback.called.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with an expired token', function() {
|
||||
beforeEach(function() {
|
||||
describe('with an expired token', function () {
|
||||
beforeEach(function () {
|
||||
this.OneTimeTokenHandler.getValueFromTokenAndExpire = sinon
|
||||
.stub()
|
||||
.yields(null, null)
|
||||
@@ -169,15 +169,15 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call the callback with a NotFoundError', function() {
|
||||
it('should call the callback with a NotFoundError', function () {
|
||||
return this.callback
|
||||
.calledWith(sinon.match.instanceOf(Errors.NotFoundError))
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with no user_id in the token', function() {
|
||||
beforeEach(function() {
|
||||
describe('with no user_id in the token', function () {
|
||||
beforeEach(function () {
|
||||
this.OneTimeTokenHandler.getValueFromTokenAndExpire = sinon
|
||||
.stub()
|
||||
.yields(null, { email: this.email })
|
||||
@@ -187,15 +187,15 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call the callback with a NotFoundError', function() {
|
||||
it('should call the callback with a NotFoundError', function () {
|
||||
return this.callback
|
||||
.calledWith(sinon.match.instanceOf(Errors.NotFoundError))
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with no email in the token', function() {
|
||||
beforeEach(function() {
|
||||
describe('with no email in the token', function () {
|
||||
beforeEach(function () {
|
||||
this.OneTimeTokenHandler.getValueFromTokenAndExpire = sinon
|
||||
.stub()
|
||||
.yields(null, { user_id: this.user_id })
|
||||
@@ -205,15 +205,15 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call the callback with a NotFoundError', function() {
|
||||
it('should call the callback with a NotFoundError', function () {
|
||||
return this.callback
|
||||
.calledWith(sinon.match.instanceOf(Errors.NotFoundError))
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with no user found', function() {
|
||||
beforeEach(function() {
|
||||
describe('with no user found', function () {
|
||||
beforeEach(function () {
|
||||
this.UserGetter.getUser.yields(null, null)
|
||||
return this.UserEmailsConfirmationHandler.confirmEmailFromToken(
|
||||
(this.token = 'mock-token'),
|
||||
@@ -221,15 +221,15 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call the callback with a NotFoundError', function() {
|
||||
it('should call the callback with a NotFoundError', function () {
|
||||
return this.callback
|
||||
.calledWith(sinon.match.instanceOf(Errors.NotFoundError))
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('with secondary email missing on user', function() {
|
||||
beforeEach(function() {
|
||||
describe('with secondary email missing on user', function () {
|
||||
beforeEach(function () {
|
||||
this.OneTimeTokenHandler.getValueFromTokenAndExpire = sinon
|
||||
.stub()
|
||||
.yields(null, { user_id: this.user_id, email: 'deleted@email.com' })
|
||||
@@ -239,7 +239,7 @@ describe('UserEmailsConfirmationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call the callback with a NotFoundError', function() {
|
||||
it('should call the callback with a NotFoundError', function () {
|
||||
return this.callback
|
||||
.calledWith(sinon.match.instanceOf(Errors.NotFoundError))
|
||||
.should.equal(true)
|
||||
|
||||
Reference in New Issue
Block a user