<commit_before>/*jshint trailing:true, white:true, indent:2, strict:true, curly:true, plusplus:true
  immed:true, eqeqeq:true, forin:true, latedef:true, newcap:true, noarg:true, undef:true */
/*jslint bitwise: true, nomen: true, indent:2 */
/*global XVOWS:true, XT:true, XM:true, _:true, setTimeout:true, clearTimeout:true, vows:true, assert:true */

(function () {
  "use strict";

  var createHash, updateHash;

  createHash = {
    name: 'Elbonia',
    abbreviation: 'EL',
    currencyAbbreviation: 'PIC',
    currencyName: 'Pico',
    currencySymbol: '!'
  };

  updateHash = {
    abbreviation: 'EB'
  };

  vows.describe('XM.Country CRUD test').addBatch({
    'CREATE': XVOWS.create('XM.Country', {
      '-> Set values': {
        topic: function (model) {
          model.set(createHash);
          return model;
        },
        'Last Error is null': function (model) {
          assert.isNull(model.lastError);
        },
        // Validation tests
        'Abbreviation must be 2 letters': function (model) {
          var err = model.validate({ abbreviation: 'TOO_LONG'});
          assert.equal(err.code, 'xt1006'); // Error code for invalid length
          assert.equal(err.params.length, 2); // The length it should be
        },
        'Currency Abbreviation must be 3 letters': function (model) {
          var err = model.validate({ currencyAbbreviation: 'TOO_LONG'});
          assert.equal(err.code, 'xt1006'); // Error code for invalid length
          assert.equal(err.params.length, 3); // The length it should be
        },
        '-> Save and READ': XVOWS.save({
          'Name is `Elbonia`': function (model) {
            assert.equal(model.get('name'), 'Elbonia');
          },
          'Abbreviation is `EL`': function (model) {
            assert.equal(model.get('abbreviation'), 'EL');
          },
          'Currency Name is `Pico`': function (model) {
            assert.equal(model.get('currencyName'), 'Pico');
          },
          'Currency Abbreviation is `PIC`': function (model) {
            assert.equal(model.get('currencyAbbreviation'), 'PIC');
          },
          '-> UPDATE': {
            topic: function (model) {
              model.set(updateHash);
              return model;
            },
            'Last Error is null': function (model) {
              assert.isNull(model.lastError);
            },
            'Abbreviation is EB': function (model) {
              assert.equal(model.get('abbreviation'), 'EB');
            },
            'Status is READY_DIRTY': function (model) {
              assert.equal(model.getStatusString(), 'READY_DIRTY');
            },
            '-> Commit': XVOWS.save({
              'Abbreviation is EB': function (model) {
                assert.equal(model.get('abbreviation'), 'EB');
              },
              '-> DESTROY': XVOWS.destroy({
                'FINISH XM.Country': function () {
                  XVOWS.next();
                }
              })
            })
          }
        })
      }
    })
  }).run();
}());<commit_msg>Make assertions use Hash values instead of strings.<commit_after>/*jshint trailing:true, white:true, indent:2, strict:true, curly:true, plusplus:true
  immed:true, eqeqeq:true, forin:true, latedef:true, newcap:true, noarg:true, undef:true */
/*jslint bitwise: true, nomen: true, indent:2 */
/*global XVOWS:true, XT:true, XM:true, _:true, setTimeout:true, clearTimeout:true, vows:true, assert:true */

(function () {
  "use strict";

  var createHash, updateHash;

  createHash = {
    name: 'Elbonia',
    abbreviation: 'EL',
    currencyAbbreviation: 'PIC',
    currencyName: 'Pico',
    currencySymbol: '!'
  };

  updateHash = {
    abbreviation: 'EB'
  };

  vows.describe('XM.Country CRUD test').addBatch({
    'CREATE': XVOWS.create('XM.Country', {
      '-> Set values': {
        topic: function (model) {
          model.set(createHash);
          return model;
        },
        'Last Error is null': function (model) {
          assert.isNull(model.lastError);
        },
        // Validation tests
        'Abbreviation must be 2 letters': function (model) {
          var err = model.validate({ abbreviation: 'TOO_LONG'});
          assert.equal(err.code, 'xt1006'); // Error code for invalid length
          assert.equal(err.params.length, 2); // The length it should be
        },
        'Currency Abbreviation must be 3 letters': function (model) {
          var err = model.validate({ currencyAbbreviation: 'TOO_LONG'});
          assert.equal(err.code, 'xt1006'); // Error code for invalid length
          assert.equal(err.params.length, 3); // The length it should be
        },
        '-> Save and READ': XVOWS.save({
          'Name is `Elbonia`': function (model) {
            assert.equal(model.get('name'), createHash.name);
          },
          'Abbreviation is `EL`': function (model) {
            assert.equal(model.get('abbreviation'), createHash.abbreviation);
          },
          'Currency Name is `Pico`': function (model) {
            assert.equal(model.get('currencyName'), createHash.currencyName);
          },
          'Currency Abbreviation is `PIC`': function (model) {
            assert.equal(model.get('currencyAbbreviation'), createHash.currencyAbbreviation);
          },
          '-> UPDATE': {
            topic: function (model) {
              model.set(updateHash);
              return model;
            },
            'Last Error is null': function (model) {
              assert.isNull(model.lastError);
            },
            'Abbreviation is EB': function (model) {
              assert.equal(model.get('abbreviation'), updateHash.abbreviation);
            },
            'Status is READY_DIRTY': function (model) {
              assert.equal(model.getStatusString(), 'READY_DIRTY');
            },
            '-> Commit': XVOWS.save({
              'Abbreviation is EB' : function (model) {
                assert.equal(model.get('abbreviation'), updateHash.abbreviation);
              },
              '-> DESTROY': XVOWS.destroy({
                'FINISH XM.Country': function () {
                  XVOWS.next();
                }
              })
            })
          }
        })
      }
    })
  }).run();
}());
{'fraction_non_alphanumeric': 0.1453702222932992, 'fraction_numerical': 0.004477850631696785, 'mean_word_length': 2.0067307692307694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3061598', 'n_tokens_mistral': 1919, 'n_tokens_neox': 1804, 'n_words': 409}