<commit_before>
// switch to testing mode
process.env.NODE_ENV = 'testing';

var utils    = require('../../lib/utils'),
    PopIt    = require('../../lib/popit');
    
module.exports = {
    
    setUp: function(cb) {
        this.popit  = new PopIt();
        this.popit.set_instance('test');
        this.Person = this.popit.model('Person');
        
        utils.delete_all_testing_databases(cb);
    },
    
    tearDown: function(cb) {
        // close the connections so that the test script can exit
        this.popit.close_db_connections(cb);
    },
    
    "person name and slug": function ( test ) {    
        test.expect( 11 );
        
        var person = new this.Person();
        test.ok( person, "got new person" );

        // initial settings
        test.equal( person.name, null, 'no name' );
        test.equal( person.slug, null, 'no slug' );

        // set a valid name
        person.name = "<NAME>";
        test.equal( person.name, "<NAME>", 'name set' );
        test.equal( person.slug, "joe-bloggs", 'slug set' );

        // change the name - should not affect slug
        person.name = "New Name";
        test.equal( person.name, "New Name",   'name changed' );
        test.equal( person.slug, "joe-bloggs", 'slug not changed' );
        
        // change slug
        person.slug = "New Slug";
        test.equal( person.name, "New Name", 'name not changed' );
        test.equal( person.slug, "new-slug", 'slug changed (and slugified)' );
        
        // clear slug and set Unicode name
        person.slug = '';
        person.name = "网页";
        test.equal( person.name, "网页", 'new chinese name saved' );
        test.equal( person.slug, "",   'slug blank as expected' );
        
        test.done();
    },
    
    "increment slug": function (test) {
      test.expect(5);
      
      var Person = this.Person;
      var joe = new Person({name: 'Joe'});
      test.equal( joe.slug, 'joe', 'slug is Joe');
      
      joe.save(function(err, doc) {
        test.ifError(err);
      
        var joe2 = new Person({name: 'Joe'});
        test.equal( joe2.slug, 'joe', 'slug is joe for second joe');
      
        joe2.save(function(err) {
          test.ifError(err);<commit_msg>Test that slug algorithm handles curly punctuation (part of #190)<commit_after>
// switch to testing mode
process.env.NODE_ENV = 'testing';

var utils    = require('../../lib/utils'),
    PopIt    = require('../../lib/popit');
    
module.exports = {
    
    setUp: function(cb) {
        this.popit  = new PopIt();
        this.popit.set_instance('test');
        this.Person = this.popit.model('Person');
        
        utils.delete_all_testing_databases(cb);
    },
    
    tearDown: function(cb) {
        // close the connections so that the test script can exit
        this.popit.close_db_connections(cb);
    },
    
    "person name and slug": function ( test ) {    
        test.expect( 13 );
        
        var person = new this.Person();
        test.ok( person, "got new person" );

        // initial settings
        test.equal( person.name, null, 'no name' );
        test.equal( person.slug, null, 'no slug' );

        // set a valid name
        person.name = "<NAME>";
        test.equal( person.name, "<NAME>", 'name set' );
        test.equal( person.slug, "joe-bloggs", 'slug set' );

        // change the name - should not affect slug
        person.name = "New Name";
        test.equal( person.name, "New Name",   'name changed' );
        test.equal( person.slug, "joe-bloggs", 'slug not changed' );
        
        // change slug
        person.slug = "New Slug";
        test.equal( person.name, "New Name", 'name not changed' );
        test.equal( person.slug, "new-slug", 'slug changed (and slugified)' );
        
        // check that punctuation correctly converted
        person.slug = ''
        person.name = "D’Angelo “Oddball” Fritz";
        test.equal( person.name, "D’Angelo “Oddball” Fritz", 'name set' );
        test.equal( person.slug, 'd\'angelo-"oddball"-fritz', 'slug set' );

        // clear slug and set Unicode name
        person.slug = '';
        person.name = "网页";
        test.equal( person.name, "网页", 'new chinese name saved' );
        test.equal( person.slug, "",   'slug blank as expected' );
        
        test.done();
    },
    
    "increment slug": function (test) {
      test.expect(5);
      
      var Person = this.Person;
      var joe = new Person({name: 'Joe'});
      test.equal( joe.slug, 'joe', 'slug is Joe');
      
      joe.save(function(err, doc) {
        test.ifError(err);
      
        var joe2 = new Person({name: 'Joe'});
        test.equal( joe2.slug, 'joe', 'slug is joe for second joe');
      
        joe2.save(function(err) {
          test.ifError(err);
{'fraction_non_alphanumeric': 0.1496145030214628, 'fraction_numerical': 0.0031256511773286103, 'mean_word_length': 1.9304029304029304, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, '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': '5681290', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1523, 'n_words': 394}