<commit_before>// var mocha = require('mocha')
var expect = require('chai').expect;

var Post = require('../models/post.js');
var mongo = require('../../lib/mongo/');

describe.only('Post', function () {

  before(function (done) {
    mongo.connect(done);
  });

  afterEach(function (done) {
    Post.dropCollection(done);
  });

  describe('findById', function () {
    var id = '55d4e64dc0102bc25450210e';
    before(function () {
      // create data
      var post = new Post({})
      post.save( function (err, post) {
        id = post._id
      });
    });

    it('should return a Post object', function (done) {

      Post.findById(id, function (err, post) {
        expect(post).to.be.an.instanceOf(Post);
        done();
      });
    });
    // obj.findById('55d4e64dc0102bc25450210e', function (err, post) {
    //   db.find({_id : ObjectID('55d4e64dc0102bc25450210e')}, function (err, post) {
    //     console.log(post)
    //     console.log(post.text)
    //     setPrototype(post.text).should.equal(result.text);
    //     db.close()
    //     done();
    //   })
    // })
  })
  describe('findAll', function () {
    var id = '55d4e64dc0102bc25450210e';
    before(function () {
      // create data
      var post = new Post({})
      post.save( function (err, post) {
        id = post._id
      });
    });
    it('should return an array of Post objects', function (done) {
      Post.findAll(function (err, postArray) {
        postArray.forEach(function (post) {
          expect(post).to.be.an.instanceOf(Post);
        })
        done();
      })
    })
  })

  describe('save', function () {
    it('should save an object to the database', function (done) {
      var id = '55d4e64dc0102bc25450210e';
      var post = new Post({_id: id})
      post.save(function (err, result) {
        console.log(result)
        expect(result._id).to.not.equal(id);
        done();
      })
    })
  })

})







<commit_msg>completed test for the post.save function<commit_after>// var mocha = require('mocha')
var expect = require('chai').expect;

var Post = require('../models/post.js');
var mongo = require('../../lib/mongo/');

describe.only('Post', function () {

  before(function (done) {
    mongo.connect(done);
  });

  afterEach(function (done) {
    Post.dropCollection(done);
  });

  describe('findById', function () {
    var id = '55d4e64dc0102bc25450210e';
    before(function () {
      // create data
      var post = new Post({})
      post.save( function (err, post) {
        id = post._id
      });
    });

    it('should return a Post object', function (done) {

      Post.findById(id, function (err, post) {
        expect(post).to.be.an.instanceOf(Post);
        done();
      });
    });
    // obj.findById('55d4e64dc0102bc25450210e', function (err, post) {
    //   db.find({_id : ObjectID('55d4e64dc0102bc25450210e')}, function (err, post) {
    //     console.log(post)
    //     console.log(post.text)
    //     setPrototype(post.text).should.equal(result.text);
    //     db.close()
    //     done();
    //   })
    // })
  })
  describe('findAll', function () {
    var id = '55d4e64dc0102bc25450210e';
    before(function () {
      // create data
      var post = new Post({})
      post.save( function (err, post) {
        id = post._id
      });
    });
    it('should return an array of Post objects', function (done) {
      Post.findAll(function (err, postArray) {
        postArray.forEach(function (post) {
          expect(post).to.be.an.instanceOf(Post);
        })
        done();
      })
    })
  })

  describe('save', function () {
    it('should save an object to the database', function (done) {
      Post.collection.count(function (count) {
        var initialCount = count;
        // var id = '55d4e64dc<PASSWORD>bc25450210e';
        var post = new Post({})
        post.save(function (err, result) {
          Post.collection.count(function (err, result) {
            expect(result).to.equal(initialCount + 1);
            done();
          })
        })
      })
    })
  })

  // describe('delete', function () {
  //   it('should give a mongo document the hidden class', function (done) {

  //   } )
  // })

})








{'fraction_non_alphanumeric': 0.17022792022792022, 'fraction_numerical': 0.039648622981956316, 'mean_word_length': 2.186838124054463, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5791941', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1373, 'n_words': 274}