<commit_before>var assert = require('assert');
var _ = require('@sailshq/lodash');

describe('Semantic Interface', function() {
  describe('.create()', function() {
    it('should create a new record', function(done) {
      Semantic.User.create({ first_name: 'Foo' }, function(err, record) {
        if (err) { 
          return done(err);
        }

        assert.equal(record.first_name, 'Foo');
        
        return done();
      });
    });

    it('should return a generated PK', function(done) {
      Semantic.User.create({ first_name: 'FooBar' }, function(err, user) {
        if (err) { 
          return done(err);
        }

        assert.equal(user.first_name, 'FooBar');
        assert(user.id);

        return done();
      });
    });

    it('should return generated timestamps', function(done) {
      Semantic.User.create({ first_name: 'Foo', last_name: 'Bar' }, function(err, user) {
        if (err) { 
          return done(err);
        }

        assert(user.createdAt);
        assert(user.updatedAt);
        
        return done();
      });
    });

    it('should normalize undefined values to null', function(done) {
      Semantic.User.create({ first_name: 'Yezy', last_name: undefined }, function(err, user) {
        if (err) { 
          return done(err);
        }

        assert.equal(user.last_name, null);
        
        return done();
      });
    });

    it('should return rows in the correct order when creating multiple rows', function(done) {
      var testName = '.create() with a list, returning values';
      var users = [];

      for(var i=0; i<30; i++) {
        users.push({ first_name: 'test_' + i, type: testName });
      }

      Semantic.User.create(users, function(err, users) {
        if (err) { 
          return done(err);
        }

        users.forEach(function(val, idx){
          assert.equal(users[idx].first_name, 'test_' + idx);
        });
        
        assert.equal(users.length, 30, 'Expecting 30 "users", but actually got '+users.length+': '+require('util').inspect(users, false, null));
        
        return done();
      });
    });

    describe('overloaded usage of create', function() {
      var testName = '.create() test create a list';

      before(function(done) {
        var users = [];

        for(var i=0; i<4; i++) {
          users.push({ first_name: 'test_' + i, type: testName });
        }

        Semantic.User.create(users, done);
      });


      it('should have saved the proper values (with auto-increment values)', function(done) {
        Semantic.User.find({where : { type: testName }, sort : {first_name : 1}}, function(err, users) {
          if (err) {
            return done(err);
          }

          
          assert.equal(users.length, 4, 'Expecting 4 "users", but actually got '+users.length+': '+require('util').inspect(users, false, null));
          assert.equal(users[0].first_name, 'test_0' );<commit_msg>don’t test createEach in create tests<commit_after>var assert = require('assert');
var _ = require('@sailshq/lodash');

describe('Semantic Interface', function() {
  describe('.create()', function() {
    it('should create a new record', function(done) {
      Semantic.User.create({ first_name: 'Foo' }, function(err, record) {
        if (err) { 
          return done(err);
        }

        assert.equal(record.first_name, 'Foo');
        
        return done();
      });
    });

    it('should return a generated PK', function(done) {
      Semantic.User.create({ first_name: 'FooBar' }, function(err, user) {
        if (err) { 
          return done(err);
        }

        assert.equal(user.first_name, 'FooBar');
        assert(user.id);

        return done();
      });
    });

    it('should return generated timestamps', function(done) {
      Semantic.User.create({ first_name: 'Foo', last_name: 'Bar' }, function(err, user) {
        if (err) { 
          return done(err);
        }

        assert(user.createdAt);
        assert(user.updatedAt);
        
        return done();
      });
    });

    it('should normalize undefined values to null', function(done) {
      Semantic.User.create({ first_name: 'Yezy', last_name: undefined }, function(err, user) {
        if (err) { 
          return done(err);
        }

        assert.equal(user.last_name, null);
        
        return done();
      });
    });

    describe('overloaded usage of create', function() {
      var testName = '.create() test create a list';

      before(function(done) {
        var users = [];

        for(var i=0; i<4; i++) {
          users.push({ first_name: 'test_' + i, type: testName });
        }

        Semantic.User.create(users, done);
      });


      it('should have saved the proper values (with auto-increment values)', function(done) {
        Semantic.User.find({where : { type: testName }, sort : {first_name : 1}}, function(err, users) {
          if (err) {
            return done(err);
          }

          
          assert.equal(users.length, 4, 'Expecting 4 "users", but actually got '+users.length+': '+require('util').inspect(users, false, null));
          assert.equal(users[0].first_name, 'test_0' );
{'fraction_non_alphanumeric': 0.1550028918449971, 'fraction_numerical': 0.004048582995951417, 'mean_word_length': 2.2084106369820655, 'pattern_counts': {'":': 0, '<': 6, '<?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': '4313224', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1516, 'n_words': 371}