<commit_before>var Model   = require('../lib/model');
var Schema  = require('../lib/schema');
var Rebound = require('../')
var es      = require('elasticsearch');
var should  = require('should');
var util    = require('./testutil');
var faker   = require('faker');

describe('Model:', function () {
  describe('create model', function () {
    it('create model without Rebound Object', function () {
      var User = new Model(
        Rebound.connection,{},
        new Schema({
          username: String,
          password: String,
          age: Number
      }));
      User.should.be.ok;
      User.should.have.properties(['connection', 'schema']);
      User.schema.should.be.instanceof(Schema);
    });
    it('create model with Rebound Object', function () {
      var UserSchema = new Schema({
        username: String,
        password: <PASSWORD>,
        age: Number
      });
      var User = Rebound.model('User', {},UserSchema);
      User.should.be.ok;
      User.should.have.properties(['connection', 'schema']);
      User.schema.should.be.instanceof(Schema);
      User.schema.should.eql(UserSchema);
    });
  });

  describe('Model CRUD', function() {
    var TestSchema = new Schema({
      name: String,
      count: Number
    });
    var TestModel = new Model(Rebound.connection, {index: 'test', type: 'text'}, TestSchema);

    describe('model create', function() {
      it('create document with doc', function() {
        return TestModel
          .create({
            name: faker.name.findName(),
            count: faker.random.number()
          })
          .then(function (result) {
            result.should.be.ok;
            result.created.should.be.true;
          });
      });
      it('create document with doc', function() {
        util.shouldThrowError(function () {
          TestModel.create({ name: faker.name.findName() });
        });
      });
    });<commit_msg>fixed tests to work with new model<commit_after>var Model   = require('../lib/model');
var Schema  = require('../lib/schema');
var Rebound = require('../')
var es      = require('elasticsearch');
var should  = require('should');
var util    = require('./testutil');
var faker   = require('faker');

describe('Model:', function () {
  describe('create model', function () {
    it('create model without Rebound Object', function () {
      var User = new Model(
        Rebound.connection,{
            index: 'test',
            type: 'test'
        },
        {},
        new Schema({
          username: String,
          password: String,
          age: Number
      }));
      User.should.be.ok;
      User.should.have.properties(['connection', 'schema']);
      User.schema.should.be.instanceof(Schema);
    });

    it('create model with Rebound Object', function () {
      var UserSchema = new Schema({
        username: String,
        password: String,
        age: Number
      });
      var User = Rebound.model('User', {},UserSchema);
      User.should.be.ok;
      User.should.have.properties(['connection', 'schema']);
      User.schema.should.be.instanceof(Schema);
      User.schema.should.eql(UserSchema);
    });
  });

  describe('Model CRUD', function() {
    var TestSchema = new Schema({
      name: String,
      count: Number
    });
    var TestModel = new Model(Rebound.connection, {}, {index: 'test', type: 'text'}, TestSchema);

    describe('model create', function() {
      it('create document with doc', function() {
        return TestModel
          .create({
            name: faker.name.findName(),
            count: faker.random.number()
          })
          .then(function (result) {
            result.should.be.ok;
            result.created.should.be.true;
          });
      });

      it('create document with doc', function() {
        util.shouldThrowError(function () {
          TestModel.create({ name: faker.name.findName() });
        });
      });
    });
{'fraction_non_alphanumeric': 0.15817626082526745, 'fraction_numerical': 0.0, 'mean_word_length': 2.2508278145695364, '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': '1260001', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1080, 'n_words': 254}