Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('User: Routes', () => {
- describe('POST /auth/signup', () => {
- it('should create user if the form is valid', (done) => {
- const data = {
- name: 'Max',
- email: 'maxfarseer@gmail.com',
- password: 'secret',
- }
- request(app)
- .post('/auth/signup')
- .send(data)
- .expect(200)
- .end((err, res) => { //eslint-disable-line no-unused-vars
- should.not.exist(err)
- User.find((err, users) => {
- users.length.should.equal(1)
- const u = users[0]
- u.name.should.equal(data.name)
- u.email.should.equal(data.email)
- should.exist(u.passwordHash)
- done()
- })
- })
- })
- it('should send errors array, if the form is invalid', (done) => {
- const data = {
- name: '',
- email: 'maxfarseer@',
- password: 'sec', //less than 4
- }
- request(app)
- .post('/auth/signup')
- .send(data)
- .expect(400)
- .end((err, res) => {
- should.not.exist(err)
- res.body.errors.should.be.an.Array()
- res.body.errors.should.have.length(2)
- done()
- })
- })
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement