<commit_before>var app = require('../../server'),
    request = require('supertest'),
    expect = require('chai').expect,
    UserModel = require('../user/model'),
    FolderModel = require('./model');

describe('[FOLDERS]'.bold.green, function() {
  var token,
      userData = {
        username: 'username-test',
        password: '<PASSWORD>',
        email: 'email-test'
      },
      folder,
      folderData = {
        name: 'folderName-test'
      };

  before(function(done) {
    UserModel.collection.drop();
    request(app)
      .post('/auth/register')
      .send(userData)
      .set('Accept', 'application/json')
      .end(function() {
        request(app)
          .post('/auth/login')
          .send(userData)
          .set('Accept', 'application/json')
          .end(function(err, res) {
            token = res.body.token;
            done();
          });
      });
  });

  beforeEach(function(done) {
    FolderModel.collection.drop();
    request(app)
      .post('/folders')
      .send(folderData)
      .set({Accept: 'application/json', Authorization: token})
      .end(function(err, res) {
        folder = res.body;
        done();
      });
  });

  describe('#get()'.cyan, function() {
    it('should get all of a users folders', function(done) {
      request(app)
        .get('/folders')
        .set({Accept: 'application/json', Authorization: token})
        .expect('Content-Type', /json/)
        .expect(200)
        .end(function(err, res) {
          expect(res.body).to.be.an('array');
          expect(res.body.length).to.eql(1);
          expect(res.body[0]).to.eql(folder);
          done();
        });
    });
  });
});<commit_msg>refactor crud spec<commit_after>var app = require('../../server'),
    request = require('supertest'),
    expect = require('chai').expect,
    UserModel = require('../user/model'),
    FolderModel = require('./model');

describe('[FOLDERS]'.bold.green, function() {
  var token,
      userData = {
        username: 'username-test',
        password: '<PASSWORD>',
        email: 'email-test'
      },
      folder,
      folderData = {
        name: 'folderName-test'
      };

  before(function(done) {
    UserModel.collection.drop();
    request(app)
      .post('/auth/register')
      .send(userData)
      .set('Accept', 'application/json')
      .end(function() {
        request(app)
          .post('/auth/login')
          .send(userData)
          .set('Accept', 'application/json')
          .end(function(err, res) {
            token = res.body.token;
            done();
          });
      });
  });

  beforeEach(function(done) {
    FolderModel.collection.drop();
    request(app)
      .post('/folders')
      .send(folderData)
      .set({Accept: 'application/json', Authorization: token})
      .end(function(err, res) {
        folder = res.body;
        done();
      });
  });

  describe('#get()'.cyan, function() {
    it('should get all of a users folders', function(done) {
      request(app)
        .get('/folders')
        .set({Accept: 'application/json', Authorization: token})
        .expect('Content-Type', /json/)
        .expect(200)
        .end(function(err, res) {
          expect(res.body).to.be.an('array');
          expect(res.body.length).to.eql(1);
          expect(res.body[0]).to.eql(folder);
          done();
        });
    });
  });

  describe('#post()'.cyan, function() {
    it('should add a new folder', function(done) {
      request(app)
        .post('/folders')
        .send(folderData)
        .set({Accept: 'application/json', Authorization: token})
        .expect('Content-Type', /json/)
        .expect(200)
        .end(function(err, res) {
          expect(res.body).to.be.an('object');
          expect(res.body).to.have.property('name', folderData.name);
          done();
        });
    });
  });

  describe('#getOne()'.cyan, function() {
    it('should get a specific folder', function(done) {
      request(app)
        .get('/folders/' + folder._id)
        .set({Accept: 'application/json', Authorization: token})
        .expect('Content-Type', /json/)
        .expect(200)
        .end(function(err, res) {
          expect(res.body).to.eql(folder);
          done();
        });
    });
  });


  describe('#put()'.cyan, function() {
    it('should update a specific folder', function(done) {
      var update = {
        name: 'updatedFolderName-test'
      };
      request(app)
        .put('/folders/' + folder._id)
        .send(update)
        .set({Accept: 'application/json', Authorization: token})
        .expect('Content-type', /json/)
        .expect(200)
        .end(function(err, res) {
          expect(res.body).to.not.eql(folder);
          expect(res.body).to.have.property('name', update.name);
          done();
        });
    });
  });

  describe('#delete()'.cyan, function() {
    it('should delete a specific folder', function(done) {
      request(app)
        .delete('/folders/' + folder._id)
        .set({Accept: 'application/json', Authorization: token})
        .expect('Content-type', /json/)
        .expect(200)
        .end(function(err, res) {
          expect(res.body).to.eql(folder);
          request(app)
            .get('/folders')
            .set({Accept: 'application/json', Authorization: token})
            .end(function(err, res) {
              expect(res.body.length).to.eql(0);
              done();
            });
        });
    });
  });
});
{'fraction_non_alphanumeric': 0.18570645220252238, 'fraction_numerical': 0.0042039846463169436, 'mean_word_length': 2.019867549668874, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4637942', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1662, 'n_words': 274}