<commit_before>const chai = require('chai');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
const expect = chai.expect;
const server = require(__dirname + '/test_server');
const origin = 'localhost:4000';
const User = require(__dirname + '/../models/user');
const request = chai.request;

var testUser = new User();
var myTestToken = testUser.generateToken();

describe('Public routes', () => {
  it('should get to /', (done) => {
    request(origin)
    .get('/')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /home', (done) => {
    request(origin)
    .get('/home')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /index', (done) => {
    request(origin)
    .get('/index')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /player', (done) => {
    request(origin)
    .get('/player')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });
});


describe('Token routes no token', () => {
  it('should FAIL TO get to /newCP', (done) => {
    request(origin)
    .post('/newCP')
    .end((err, res) => {
      expect(res).to.have.status(401);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should FAIL TO get to /profile', (done) => {
    request(origin)
    .get('/profile')
    .end((err, res) => {
      expect(res).to.have.status(401);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should FAIL TO get to /player2', (done) => {
    request(origin)
    .get('/player2')
    .end((err, res) => {
      expect(res).to.have.status(401);
      expect(err).to.eql(null);
      done();
    });
  });
});

describe('Token routes with token', () => {
  before((done) => {
    User.create({ email: '<EMAIL>', password: '<PASSWORD>' }, (err, data) => {
      if (err) throw err;
      this.token = data.generateToken();
      done();
    });
  });

  it('should get to /newCP', (done) => {
    request(origin)
    .post('/newCP')
    .set('token', this.token)
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /profile', (done) => {
    request(origin)
    .get('/profile')
    .set('token', this.token)
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /player2', (done) => {
    request(origin)
    .get('/player2')
    .set('token', this.token)
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });
});

server.fake = null;
<commit_msg>Fixed /player test issue<commit_after>const chai = require('chai');
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
const expect = chai.expect;
const server = require(__dirname + '/test_server');
const origin = 'localhost:4000';
const User = require(__dirname + '/../models/user');
const request = chai.request;

describe('Public routes', () => {
  it('should get to /', (done) => {
    request(origin)
    .get('/')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /home', (done) => {
    request(origin)
    .get('/home')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /index', (done) => {
    request(origin)
    .get('/index')
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });
});


describe('Token routes no token', () => {
  it('should FAIL TO get to /newCP', (done) => {
    request(origin)
    .post('/newCP')
    .end((err, res) => {
      expect(res).to.have.status(401);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should FAIL TO get to /profile', (done) => {
    request(origin)
    .get('/profile')
    .end((err, res) => {
      expect(res).to.have.status(401);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should FAIL TO get to /player2', (done) => {
    request(origin)
    .get('/player2')
    .end((err, res) => {
      expect(res).to.have.status(401);
      expect(err).to.eql(null);
      done();
    });
  });
});

describe('Token routes with token', () => {
  before((done) => {
    User.create({ email: '<EMAIL>', password: '<PASSWORD>' }, (err, data) => {
      if (err) throw err;
      this.token = data.generateToken();
      done();
    });
  });

  it('should get to /newCP', (done) => {
    request(origin)
    .post('/newCP')
    .set('token', this.token)
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /profile', (done) => {
    request(origin)
    .get('/profile')
    .set('token', this.token)
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });

  it('should get to /player2', (done) => {
    request(origin)
    .get('/player2')
    .set('token', this.token)
    .end((err, res) => {
      expect(res).to.have.status(200);
      expect(err).to.eql(null);
      done();
    });
  });
});

server.fake = null;

{'fraction_non_alphanumeric': 0.2297979797979798, 'fraction_numerical': 0.013167388167388168, 'mean_word_length': 2.4962168978562422, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 55, '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': '4967373', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1975, 'n_words': 362}