/* eslint-disable amd, import/no-unresolved */
const app = require('../../server');
const request = require('supertest');
const mongoose = require('mongoose');
const users = require('../../app/controllers/users');

const User = mongoose.model('User');

let user = '';

describe('User Authentication', () => {
  beforeEach((done) => {
    user = new User({
      name: 'Full name',
      email: 'test@tesing.com',
      username: 'user1',
      password: 'password'
    });
    user.save(done);
  });

  afterEach((done) => {
    done();
  });
  describe('Login', () => {
    it('should redirect to login page when login is click', (done) => {
      request(app).get('/signin')
        .expect(302, done());
    });

    it('should login for valid user', (done) => {
      request(app).post('/users')
        .send({
          email: user.email,
          password: user.password
        })
        .expect(302, done());
    });
  });
  describe('SignUp', () => {
    it('should rediret to the sign up page when sign up is click', (done) => {
      request(app).get('/signup')
        .expect(302, done());
    });

    it('should sign up when valid data is passed', (done) => {
      request(app).post('/users', users.create)
        .send({
          name: 'Full name',
          email: 'test@tesing.com',
          username: 'user1',
          password: 'password'
        })
        .expect(302, done());
    });
  });
});

@@ -19,29 +19,8 @@
 amd,
- import/no-unresolved
  */%0A
@@ -761,112 +761,100 @@
 pp).
-pos
+ge
 t('/
-users')%0A        .send(%7B%0A          email: user.email,%0A          password: user.password%0A  
+signin', (req, res) =%3E %7B%0A        users.session(req, res);%0A        res.send();%0A
       %7D)
 %0A   
@@ -845,33 +845,44 @@
 ();%0A      %7D)
+;
 %0A
- 
       
- 
+request(app)
 .expect(302,

refactor test to increase coverage [Finishes #134209527]