<commit_before>process.env.NODE_ENV = 'test';

var chai = require('chai');
var chaiHttp = require('chai-http');
var mongoose = require('mongoose-q')(require('mongoose'));
var passportStub = require('passport-stub');

var app = require('../../src/server/app');
var Product = require('../../src/server/models/product.js');
var User = require('../../src/server/models/user.js');
var should = chai.should();

chai.use(chaiHttp);


describe('api.js Routes', function() {

  beforeEach(function(done) {

    mongoose.connection.db.dropDatabase();

    var newProduct = new Product({
      name: 'Coconut Water',
      amount: 5,
      currency: 'USD',
      forSale: true
    });

    var newUser = new User({
      email: '<EMAIL>',
      password: '<PASSWORD>',
      admin: true,
      products: [{token:'12345'}]
    });

    newUser.saveQ()
    .then(function(){
      newProduct.saveQ()
      .then(function(){
        passportStub.install(app);
        passportStub.login(newUser);
        done();
      });
    });

  });

  afterEach(function(done) {
    passportStub.logout();
    mongoose.connection.db.dropDatabase();
    done();
  });

  describe('GET api/v1/users', function(){
    it ('should return all users', function(done) {
      chai.request(app)
      .get('/api/v1/users')
      .end(function (err, res) {
        res.should.have.status(200);
        res.should.be.json;  // jshint ignore:line
        res.body.status.should.equal('success');
        res.body.data.length.should.equal(1);
        res.body.data[0].email.should.equal('<EMAIL>');
        res.body.data[0].admin.should.equal(true);
        res.body.message.should.equal('Retrieved users.');
        res.body.should.be.instanceof(Object);<commit_msg>increased test time<commit_after>process.env.NODE_ENV = 'test';

var chai = require('chai');
var chaiHttp = require('chai-http');
var mongoose = require('mongoose-q')(require('mongoose'));
var passportStub = require('passport-stub');

var app = require('../../src/server/app');
var Product = require('../../src/server/models/product.js');
var User = require('../../src/server/models/user.js');
var should = chai.should();

chai.use(chaiHttp);


describe('api.js Routes', function() {

  before(function(done) {

    mongoose.connection.db.dropDatabase();

    var newProduct = new Product({
      name: 'Coconut Water',
      amount: 5,
      currency: 'USD',
      forSale: true
    });

    var newUser = new User({
      email: '<EMAIL>',
      password: '<PASSWORD>',
      admin: true,
      products: [{token:'12345'}]
    });

    newUser.saveQ()
    .then(function(){
      newProduct.saveQ()
      .then(function(){
        passportStub.install(app);
        passportStub.login(newUser);
        done();
      });
    });

  });

  after(function(done) {
    passportStub.logout();
    mongoose.connection.db.dropDatabase();
    done();
  });

  describe('GET api/v1/users', function(){
    it ('should return all users', function(done) {
      chai.request(app)
      .get('/api/v1/users')
      .end(function (err, res) {
        res.should.have.status(200);
        res.should.be.json;  // jshint ignore:line
        res.body.status.should.equal('success');
        res.body.data.length.should.equal(1);
        res.body.data[0].email.should.equal('<EMAIL>');
        res.body.data[0].admin.should.equal(true);
        res.body.message.should.equal('Retrieved users.');
        res.body.should.be.instanceof(Object);
{'fraction_non_alphanumeric': 0.18507807981492191, 'fraction_numerical': 0.008097165991902834, 'mean_word_length': 2.8136714443219404, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6577699', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1135, 'n_words': 187}