<commit_before>let app = 'http://hawk.io:3000';

let chai = require('chai'),
    chaiHttp = require('chai-http'),
    expect = chai.expect,
    should = chai.should();

chai.use(chaiHttp);

describe('/login page', function() {

  /**
   * Open Login page
   */
  it ('Check /login page', function(done) {

      chai.request(app)
        .get('/login')
        .end(function(err, res) {

            expect(res.status).to.equal(200);
            expect(err).to.be.null;
            done();

        });

  });

  it ('Test login page. Case 1: When user has correct cookies', function(done) {

    chai.request(app)
      .get('/login')
      .end(function(err, res) {
        // console.log("error", err);
        // console.log("response", res);

        done();
      });

  });

  it ('Test login page. Case 2: When user has not cookies', function(done) {

    chai.request(app)
      .get('/login')
      .end(function(err, res) {

        done();
      });

  });

  it ('Test login page. Case 3: When data is empty', function(done) {
    done();
  });

  it ('Test POST request. Send correct data', function(done) {
    done();
  });

  it ('Test POST request. Send incorrect data', function(done) {
    done();
  });

  it ('Test POST request. Send empty data', function(done) {
    done();
  });

});<commit_msg>check all cases for /login route<commit_after>let protocol = 'http',
    domain   = 'hawk.io',
    port     = '3000';
    app      = protocol + '://' + domain + ':' + port;

let chai = require('chai'),
    chaiHttp = require('chai-http'),
    expect = chai.expect,
    assert = chai.assert,
    should = chai.should();

chai.use(chaiHttp);

describe('Testing Routes: /login page', function() {

  /**
   * Open Login page
   * 1) Request must return page with 200 status
   * 2) Response mustn't contain any errors
   * 3) Expect text/html content-type
   */
  it ('Check /login page', function(done) {

      chai.request(app)
        .get('/login')
        .end(function(err, res) {

            assert.equal(res.status, 200, 'Request returns page with 200 status')
            expect(res.headers['content-type']).to.be.equal('text/html; charset=utf-8');
            expect(err).to.be.null;
            done();

        });

  });

  /**
   * User gets login page with correct cookies:
   * If user has correct data, he must be redirected to /garage
   */
  it ('Case 1 #GET: User has correct cookies', function(done) {

    chai.request(app)
      .get('/login')
      .set('Cookie', '_csrf=i1YNofMeM05axYRn52xpXQXr; user_id=5953d6cf3e89e4000f6eade4; user_hash=35ba436493f5a2cbb73071d1df31cfe2027ad2c338329d5d389acfdc3ec2071c')
      .end(function(err, res) {

        expect(res.redirects[0]).to.be.equal(app + '/garage');
        expect(err).to.be.null;
        done();

      });

  });

  /**
   * If user doesn't have any cookie, he must see login page with form
   * content-type must be text/html
   */
  it ('Case 2 #GET: User does not have cookies', function(done) {

    chai.request(app)
      .get('/login')
      .end(function(err, res) {

        assert.equal(res.status, 200, 'Request returns page with 200 status')
        assert.equal(res.redirects.length, 0, 'see login form');
        expect(res.headers['content-type']).to.be.equal('text/html; charset=utf-8');
        expect(err).to.be.null;

        done();

      });

  });

  /**
   * After authentification user must be redirected to the /garage
   * content-type: text/html
   */
  it ('Case 3 #POST: Send correct data', function(done) {

    let email    = '<EMAIL>',
        password = '<PASSWORD>';

    chai.request(app)
      .post('/login')
      .send({
        'email' : email,
        'password' : password
      })
      .end(function(err, res) {

          expect(res.redirects[0]).to.be.equal(app + '/garage');
          expect(err).to.be.null;
          done();

      });

  });

  /**
   * If POST data is not correct, show 'Try again' page
   * content-type: text/html
   */
  it ('Case 4 #POST: Send incorrect data', function(done) {

    let email    = '<EMAIL>',
        password = '<PASSWORD>';

    chai.request(app)
      .post('/login')
      .send({
        'email' : email,
        'password' : password
      })
      .end(function(err, res) {

          assert.equal(res.status, 200, 'Request returns page with 200 status')
          assert.equal(res.redirects.length, 0, 'see login form');
          expect(res.headers['content-type']).to.be.equal('text/html; charset=utf-8');
          expect(err).to.be.null;
          done();

      });

  });

  /**
   * Must refresh page or show login page
   * content-type: text/html
   */
  it ('Case 5 #POST: Send empty data', function(done) {

    chai.request(app)
      .post('/login')
      .send({
        'email' : null,
        'password' : null
      })
      .end(function(err, res) {

          assert.equal(res.status, 200, 'Request returns page with 200 status')
          assert.equal(res.redirects.length, 0, 'see login form');
          expect(res.headers['content-type']).to.be.equal('text/html; charset=utf-8');
          expect(err).to.be.null;
          done();

      });
    
  });

});
{'fraction_non_alphanumeric': 0.16608729239088452, 'fraction_numerical': 0.02220934723831595, 'mean_word_length': 2.2449874686716793, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2067851', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1675, 'n_words': 401}