<commit_before>'use strict';
import {seed} from '../../config/seed';
import {getSessionFor} from '../../auth/util.integration';
import Project from '../project/project.model';

var should = require('should');
var app = require('../../app');
var request = require('supertest');
var agent = request.agent(app);
var project = request.agent();

describe('GET /api/projects', function() {

  it('should respond with JSON array', function(done) {
    request(app)
      .get('/api/projects')
      .expect(200)
      .expect('Content-Type', /json/)
      .end(function(err, res) {
        if (err) return done(err);
        res.body.should.be.instanceof(Array);
        done();
      });
  });
});

describe('GET /api/projects/past', function() {

  it('should respond with JSON array', function(done) {
    request(app)
      .get('/api/projects/past')
      .expect(200)
      .expect('Content-Type', /json/)
      .end(function(err, res) {
        if (err) return done(err);
        res.body.should.be.instanceof(Array);
        done();
      });
  });
});

describe('POST /api/projects/', function() {
  before(seed);
  var studentSession;
  var adminSession;
  before(() => getSessionFor('student').then(session => studentSession = session));
  before(() => getSessionFor('admin').then(session => adminSession = session));

  it('Should create a session', function(done) {
    agent.post('/api/users')
      .send({ username: '<EMAIL>', password: '<PASSWORD>' })
      .expect('Content-Type',/json/)
      .end(function(err, res) {
        expect(res.status).to.equal(200);
        done();
      });
  });

  it('Should return the current session', function(done) {
    agent.get('/api/projects').end(function(err, res) {
      expect(res.status).to.equal(200);
      done();
    });
  });

  it('Should create a project',done => {
    studentSession
      .post('/api/projects/')
      .send({
        title: "Test Project",
        description: "Testing",
        websiteUrl: "www.google.com"
      })
    .end((err,res) => {
      expect(res.status).to.equal(201);
      done(err);
    });
  });

  it('Should delete a project', done=> {
    var test_id = "000000000000000000000010";
    adminSession
      .delete('/api/projects/'+test_id)
      .end((err,res) => {
        expect(res.status).to.equal(204);
        done(err);
      });
  });

});<commit_msg>Added tests that check if project creation and deletion work<commit_after>'use strict';
import {seed} from '../../config/seed';
import {getSessionFor} from '../../auth/util.integration';
import Project from '../project/project.model';

var should = require('should');
var app = require('../../app');
var request = require('supertest');
var agent = request.agent(app);
var project = request.agent();

describe('GET /api/projects', function() {

  it('should respond with JSON array', function(done) {
    request(app)
      .get('/api/projects')
      .expect(200)
      .expect('Content-Type', /json/)
      .end(function(err, res) {
        if (err) return done(err);
        res.body.should.be.instanceof(Array);
        done();
      });
  });
});

describe('GET /api/projects/past', function() {

  it('should respond with JSON array', function(done) {
    request(app)
      .get('/api/projects/past')
      .expect(200)
      .expect('Content-Type', /json/)
      .end(function(err, res) {
        if (err) return done(err);
        res.body.should.be.instanceof(Array);
        done();
      });
  });
});

describe('POST /api/projects/', function() {
  before(seed);
  var studentSession;
  var adminSession;
  before(() => getSessionFor('student').then(session => studentSession = session));
  before(() => getSessionFor('admin').then(session => adminSession = session));

  it('Should create a session', function(done) {
    agent.post('/api/users')
      .send({ username: '<EMAIL>', password: '<PASSWORD>' })
      .expect('Content-Type',/json/)
      .end(function(err, res) {
        expect(res.status).to.equal(200);
        done();
      });
  });

  it('Should return the current session', function(done) {
    agent.get('/api/projects').end(function(err, res) {
      expect(res.status).to.equal(200);
      done();
    });
  });

  it('Should create a project',done => {
    studentSession
      .post('/api/projects/')
      .send({
        title: "Test Project",
        description: "Testing",
        websiteUrl: "www.google.com"
      })
<<<<<<< HEAD
    .end((err,res) => {
      expect(res.status).to.equal(201);
      done(err);
    });
=======
      .end((err,res) => {
        expect(res.status).to.equal(201);
        done(err);
     });
>>>>>>> 54979d6... Added tests that check if project creation and deletion work
  });

  it('Should delete a project', done=> {
    var test_id = "000000000000000000000010";
    adminSession
      .delete('/api/projects/'+test_id)
      .end((err,res) => {
        expect(res.status).to.equal(204);
        done(err);
<<<<<<< HEAD
      });
=======
     });
>>>>>>> 54979d6... Added tests that check if project creation and deletion work
  });

});
{'fraction_non_alphanumeric': 0.19673099645529737, 'fraction_numerical': 0.019495864513588028, 'mean_word_length': 2.781831720029784, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5267280', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1546, 'n_words': 326}