mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
reformtted reg handler tests
This commit is contained in:
parent
e4223c9b5e
commit
2ca7c344a3
2 changed files with 65 additions and 56 deletions
|
@ -28,3 +28,9 @@ module.exports =
|
|||
callback('not valid email', null)
|
||||
else
|
||||
callback(null, {first_name:first_name, last_name:last_name, email:email, password:password})
|
||||
|
||||
|
||||
|
||||
registerNewUser: (userDetails, callback)->
|
||||
|
||||
callback()
|
|
@ -4,64 +4,67 @@ assert = require('assert')
|
|||
path = require('path')
|
||||
modulePath = path.join __dirname, '../../../../app/js/Features/User/UserRegistrationHandler'
|
||||
|
||||
|
||||
|
||||
describe 'validate Register Request', ->
|
||||
passingRequest = undefined
|
||||
controller = undefined
|
||||
describe "UserRegistrationHandler", ->
|
||||
|
||||
beforeEach ->
|
||||
controller = SandboxedModule.require modulePath, requires:{}
|
||||
passingRequest = {body:{email:"something@email.com", password:"123"}}
|
||||
@handler = SandboxedModule.require modulePath, requires:{}
|
||||
@passingRequest = {body:{email:"something@email.com", password:"123"}}
|
||||
|
||||
it 'allow working account through', ->
|
||||
controller.validateRegisterRequest passingRequest, (err, data)->
|
||||
should.not.exist(err)
|
||||
data.first_name.should.equal "something"
|
||||
data.last_name.should.equal ""
|
||||
data.email.should.equal passingRequest.body.email
|
||||
data.password.should.equal passingRequest.body.password
|
||||
|
||||
it 'not allow not valid email through ', (done)->
|
||||
passingRequest.body.email = "notemail"
|
||||
controller.validateRegisterRequest passingRequest, (err, data)->
|
||||
should.exist(err)
|
||||
err.should.equal "not valid email"
|
||||
done()
|
||||
|
||||
it 'not allow no email through ', ->
|
||||
passingRequest.body.email = ""
|
||||
controller.validateRegisterRequest passingRequest, (err, data)->
|
||||
should.exist(err)
|
||||
err.should.equal "please fill in all the fields"
|
||||
|
||||
it 'not allow no password through ', (done)->
|
||||
passingRequest.body.password= ""
|
||||
controller.validateRegisterRequest passingRequest, (err, data)->
|
||||
should.exist(err)
|
||||
err.should.equal "please fill in all the fields"
|
||||
done()
|
||||
|
||||
it 'trim white space from email', (done)->
|
||||
passingRequest.body.email = " some@email.com "
|
||||
controller.validateRegisterRequest passingRequest, (err, data)->
|
||||
should.not.exist(err)
|
||||
data.email.should.equal "some@email.com"
|
||||
done()
|
||||
describe 'validate Register Request', ->
|
||||
|
||||
|
||||
it 'allow working account through', ->
|
||||
@handler.validateRegisterRequest @passingRequest, (err, data)=>
|
||||
should.not.exist(err)
|
||||
data.first_name.should.equal "something"
|
||||
data.last_name.should.equal ""
|
||||
data.email.should.equal @passingRequest.body.email
|
||||
data.password.should.equal @passingRequest.body.password
|
||||
|
||||
it 'not allow not valid email through ', (done)->
|
||||
@passingRequest.body.email = "notemail"
|
||||
@handler.validateRegisterRequest @passingRequest, (err, data)->
|
||||
should.exist(err)
|
||||
err.should.equal "not valid email"
|
||||
done()
|
||||
|
||||
it 'not allow no email through ', ->
|
||||
@passingRequest.body.email = ""
|
||||
@handler.validateRegisterRequest @passingRequest, (err, data)->
|
||||
should.exist(err)
|
||||
err.should.equal "please fill in all the fields"
|
||||
|
||||
it 'not allow no password through ', (done)->
|
||||
@passingRequest.body.password= ""
|
||||
@handler.validateRegisterRequest @passingRequest, (err, data)->
|
||||
should.exist(err)
|
||||
err.should.equal "please fill in all the fields"
|
||||
done()
|
||||
|
||||
it 'trim white space from email', (done)->
|
||||
@passingRequest.body.email = " some@email.com "
|
||||
@handler.validateRegisterRequest @passingRequest, (err, data)->
|
||||
should.not.exist(err)
|
||||
data.email.should.equal "some@email.com"
|
||||
done()
|
||||
|
||||
it 'lower case email', (done)->
|
||||
@passingRequest.body.email = "soMe@eMail.cOm"
|
||||
@handler.validateRegisterRequest @passingRequest, (err, data)->
|
||||
should.not.exist(err)
|
||||
data.email.should.equal "some@email.com"
|
||||
done()
|
||||
|
||||
it 'should allow a short registeration request through', (done) ->
|
||||
@handler.validateRegisterRequest body: {
|
||||
email: "user_name@example.com"
|
||||
password: @passingRequest.body.password
|
||||
}, (err, data) =>
|
||||
should.not.exist(err)
|
||||
data.email.should.equal "user_name@example.com"
|
||||
data.password.should.equal @passingRequest.body.password
|
||||
data.first_name.should.equal "user_name"
|
||||
done()
|
||||
|
||||
it 'lower case email', (done)->
|
||||
passingRequest.body.email = "soMe@eMail.cOm"
|
||||
controller.validateRegisterRequest passingRequest, (err, data)->
|
||||
should.not.exist(err)
|
||||
data.email.should.equal "some@email.com"
|
||||
done()
|
||||
|
||||
it 'should allow a short registeration request through', (done) ->
|
||||
controller.validateRegisterRequest body: {
|
||||
email: "user_name@example.com"
|
||||
password: passingRequest.body.password
|
||||
}, (err, data) ->
|
||||
should.not.exist(err)
|
||||
data.email.should.equal "user_name@example.com"
|
||||
data.password.should.equal passingRequest.body.password
|
||||
data.first_name.should.equal "user_name"
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue