mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 22:29:01 +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 sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const EmailHelper = require('../../../../app/src/Features/Helpers/EmailHelper')
|
||||
|
||||
describe('UserRegistrationHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('UserRegistrationHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.user = { _id: (this.user_id = '31j2lk21kjl') }
|
||||
this.User = { updateOne: sinon.stub().callsArgWith(2) }
|
||||
this.UserGetter = { getUserByAnyEmail: sinon.stub() }
|
||||
@@ -64,22 +64,22 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('validate Register Request', function() {
|
||||
it('allows passing validation through', function() {
|
||||
describe('validate Register Request', function () {
|
||||
it('allows passing validation through', function () {
|
||||
const result = this.handler._registrationRequestIsValid(
|
||||
this.passingRequest
|
||||
)
|
||||
return result.should.equal(true)
|
||||
})
|
||||
|
||||
describe('failing email validation', function() {
|
||||
beforeEach(function() {
|
||||
describe('failing email validation', function () {
|
||||
beforeEach(function () {
|
||||
return this.AuthenticationManager.validateEmail.returns({
|
||||
message: 'email not set'
|
||||
})
|
||||
})
|
||||
|
||||
it('does not allow through', function() {
|
||||
it('does not allow through', function () {
|
||||
const result = this.handler._registrationRequestIsValid(
|
||||
this.passingRequest
|
||||
)
|
||||
@@ -87,14 +87,14 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('failing password validation', function() {
|
||||
beforeEach(function() {
|
||||
describe('failing password validation', function () {
|
||||
beforeEach(function () {
|
||||
return this.AuthenticationManager.validatePassword.returns({
|
||||
message: 'password is too short'
|
||||
})
|
||||
})
|
||||
|
||||
it('does not allow through', function() {
|
||||
it('does not allow through', function () {
|
||||
const result = this.handler._registrationRequestIsValid(
|
||||
this.passingRequest
|
||||
)
|
||||
@@ -103,9 +103,9 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('registerNewUser', function() {
|
||||
describe('holdingAccount', function(done) {
|
||||
beforeEach(function() {
|
||||
describe('registerNewUser', function () {
|
||||
describe('holdingAccount', function (done) {
|
||||
beforeEach(function () {
|
||||
this.user.holdingAccount = true
|
||||
this.handler._registrationRequestIsValid = sinon.stub().returns(true)
|
||||
return this.UserGetter.getUserByAnyEmail.callsArgWith(
|
||||
@@ -115,14 +115,14 @@ describe('UserRegistrationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should not create a new user if there is a holding account there', function(done) {
|
||||
it('should not create a new user if there is a holding account there', function (done) {
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.UserCreator.createNewUser.called.should.equal(false)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should set holding account to false', function(done) {
|
||||
it('should set holding account to false', function (done) {
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
const update = this.User.updateOne.args[0]
|
||||
assert.deepEqual(update[0], { _id: this.user._id })
|
||||
@@ -132,8 +132,8 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('invalidRequest', function() {
|
||||
it('should not create a new user if the the request is not valid', function(done) {
|
||||
describe('invalidRequest', function () {
|
||||
it('should not create a new user if the the request is not valid', function (done) {
|
||||
this.handler._registrationRequestIsValid = sinon.stub().returns(false)
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
expect(err).to.exist
|
||||
@@ -142,7 +142,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return email registered in the error if there is a non holdingAccount there', function(done) {
|
||||
it('should return email registered in the error if there is a non holdingAccount there', function (done) {
|
||||
this.UserGetter.getUserByAnyEmail.callsArgWith(
|
||||
1,
|
||||
null,
|
||||
@@ -160,13 +160,13 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('validRequest', function() {
|
||||
beforeEach(function() {
|
||||
describe('validRequest', function () {
|
||||
beforeEach(function () {
|
||||
this.handler._registrationRequestIsValid = sinon.stub().returns(true)
|
||||
return this.UserGetter.getUserByAnyEmail.callsArgWith(1)
|
||||
})
|
||||
|
||||
it('should create a new user', function(done) {
|
||||
it('should create a new user', function (done) {
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.UserCreator.createNewUser
|
||||
.calledWith({
|
||||
@@ -180,7 +180,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('lower case email', function(done) {
|
||||
it('lower case email', function (done) {
|
||||
this.passingRequest.email = 'soMe@eMail.cOm'
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.UserCreator.createNewUser.args[0][0].email.should.equal(
|
||||
@@ -190,7 +190,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('trim white space from email', function(done) {
|
||||
it('trim white space from email', function (done) {
|
||||
this.passingRequest.email = ' some@email.com '
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.UserCreator.createNewUser.args[0][0].email.should.equal(
|
||||
@@ -200,7 +200,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should set the password', function(done) {
|
||||
it('should set the password', function (done) {
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.AuthenticationManager.setUserPassword
|
||||
.calledWith(this.user, this.passingRequest.password)
|
||||
@@ -209,7 +209,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should add the user to the newsletter if accepted terms', function(done) {
|
||||
it('should add the user to the newsletter if accepted terms', function (done) {
|
||||
this.passingRequest.subscribeToNewsletter = 'true'
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.NewsLetterManager.subscribe
|
||||
@@ -219,7 +219,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not add the user to the newsletter if not accepted terms', function(done) {
|
||||
it('should not add the user to the newsletter if not accepted terms', function (done) {
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.NewsLetterManager.subscribe
|
||||
.calledWith(this.user)
|
||||
@@ -228,7 +228,7 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should track the registration event', function(done) {
|
||||
it('should track the registration event', function (done) {
|
||||
return this.handler.registerNewUser(this.passingRequest, err => {
|
||||
this.AnalyticsManager.recordEvent
|
||||
.calledWith(this.user._id, 'user-registered')
|
||||
@@ -238,13 +238,13 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call the ReferalAllocator', function(done) {
|
||||
it('should call the ReferalAllocator', function (done) {
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
describe('registerNewUserAndSendActivationEmail', function() {
|
||||
beforeEach(function() {
|
||||
describe('registerNewUserAndSendActivationEmail', function () {
|
||||
beforeEach(function () {
|
||||
this.email = 'Email@example.com'
|
||||
this.crypto.randomBytes = sinon.stub().returns({
|
||||
toString: () => {
|
||||
@@ -259,8 +259,8 @@ describe('UserRegistrationHandler', function() {
|
||||
return (this.callback = sinon.stub())
|
||||
})
|
||||
|
||||
describe('with a new user', function() {
|
||||
beforeEach(function() {
|
||||
describe('with a new user', function () {
|
||||
beforeEach(function () {
|
||||
this.user.email = this.email.toLowerCase()
|
||||
this.handler.registerNewUser.callsArgWith(1, null, this.user)
|
||||
return this.handler.registerNewUserAndSendActivationEmail(
|
||||
@@ -269,7 +269,7 @@ describe('UserRegistrationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should ask the UserRegistrationHandler to register user', function() {
|
||||
it('should ask the UserRegistrationHandler to register user', function () {
|
||||
return this.handler.registerNewUser
|
||||
.calledWith({
|
||||
email: this.email,
|
||||
@@ -278,7 +278,7 @@ describe('UserRegistrationHandler', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should generate a new password reset token', function() {
|
||||
it('should generate a new password reset token', function () {
|
||||
const data = {
|
||||
user_id: this.user._id.toString(),
|
||||
email: this.user.email
|
||||
@@ -288,7 +288,7 @@ describe('UserRegistrationHandler', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should send a registered email', function() {
|
||||
it('should send a registered email', function () {
|
||||
return this.EmailHandler.sendEmail
|
||||
.calledWith('registered', {
|
||||
to: this.user.email,
|
||||
@@ -297,7 +297,7 @@ describe('UserRegistrationHandler', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should return the user', function() {
|
||||
it('should return the user', function () {
|
||||
return this.callback
|
||||
.calledWith(
|
||||
null,
|
||||
@@ -308,8 +308,8 @@ describe('UserRegistrationHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a user that already exists', function() {
|
||||
beforeEach(function() {
|
||||
describe('with a user that already exists', function () {
|
||||
beforeEach(function () {
|
||||
this.handler.registerNewUser.callsArgWith(
|
||||
1,
|
||||
new Error('EmailAlreadyRegistered'),
|
||||
@@ -321,7 +321,7 @@ describe('UserRegistrationHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should still generate a new password token and email', function() {
|
||||
it('should still generate a new password token and email', function () {
|
||||
this.OneTimeTokenHandler.getNewToken.called.should.equal(true)
|
||||
return this.EmailHandler.sendEmail.called.should.equal(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user