<commit_before>var should = require('should');
process.env.NODE_ENV = 'mocha';
process.env.DB = 'test_iasurvey';
var app = require('../app.js');

// wait for server to start before testing
describe('IA App', function() {
  before(function(done) {
    // wait for the controller to become available
    var checkFinished = function() {
      if(app.get('controller') === undefined) {
        setTimeout(checkFinished, 10);
      } else {
        done();
      }
    };
    checkFinished();
  });

  it('should be able to clear the database', function(done) {
    // get a handle on the controller
    var db = app.get('db');

    // setup a function to call only when all callbacks have returned
    var todo = 4;
    var completed = function(){
      if(--todo === 0){
        done();
      }
    };

    db.survey.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });

    db.staff.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });

    db.result.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });

    db.log.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });
  });
<commit_msg>add some comments<commit_after>var should = require('should');
process.env.NODE_ENV = 'mocha';
process.env.DB = 'test_iasurvey';
var app = require('../app.js');

// wait for server to start before testing
describe('IA App', function() {
  before(function(done) {
    // wait for the controller to become available
    var checkFinished = function() {
      if(app.get('controller') === undefined) {
        setTimeout(checkFinished, 10);
      } else {
        done();
      }
    };
    checkFinished();
  });

  it('should be able to clear the database', function(done) {
    // get a handle on the controller
    var db = app.get('db');

    // setup a function to call only when all callbacks have returned
    var todo = 4;
    var completed = function(){
      if(--todo === 0){
        done();
      }
    };

    // remove all the surveys
    db.survey.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });

    // remove all the staff
    db.staff.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });

    // remove all the results
    db.result.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });

    // remove all the logs
    db.log.remove({}, {multi: true}, function(err, numRemoved){
      (err === null).should.be.equal(true);
      completed();
    });
  });

{'fraction_non_alphanumeric': 0.17348723329835608, 'fraction_numerical': 0.0027981811822315496, 'mean_word_length': 2.6248415716096325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6665443', 'n_tokens_mistral': 887, 'n_tokens_neox': 864, 'n_words': 232}