<commit_before>/**
 * Created on 8/23/16.
 */
'use strict';


var hash = require('../hash2');
var assert = require('chai').assert;

var hashSC = hash();
var hashS = hash({coerce: false});
var hashC = hash({sort: false});

var libName = 'node-object-hash-v2';

var objects = {
  a: {
    b: 1,
    c: 3,
    a: 4,
    f: 0
  },
  b: {
    c: 3,
    b: 1,
    f: 0,
    a: 4
  },
  c: {
    c: '3',
    b: 1,
    f: '0',
    a: 4
  },
  d: [4, 3, 0, 2, 1],
  e: [2, '4', '3', false, true],
  f: {
    a: [{c: 2, a: 1, b: {a: 3, c: 2, b: 0}}],
    b: [1, 'a', {}, null],
  },
  g: {
    b: ['a', 1, {}, undefined],
    a: [{c: '2', b: {b: false, c: 2, a: '3'}, a: true}]
  },
  h: {
    type: 'ui',
    key: {
      code: 'BLA'
    }
  },
  i: {
    type: 'ui',
    key: {
      code: 'BLA'
    }
  }
};

describe(libName, () => {
  describe('#hash() on objects: [sort=true, coerce=true]', () => {
    it('should return equal hashes', () => {
      assert.equal(hashSC.hash(objects.a), hashSC.hash(objects.c));
    });
  });
  describe('#hash() on objects: [sort=true, coerce=false]', () => {
    it('should return equal hashes', () => {
      assert.equal(hashS.hash(objects.a), hashS.hash(objects.b));
    });
  });
  describe('#hash() on objects: [sort=false, coerce=true]', () => {
    it('should return equal hashes', () => {
      assert.equal(hashC.hash(objects.c), hashC.hash(objects.b));
    });
  });
  describe('#hash() on arrays: [sort=true, coerce=true]', () => {
    it('should return equal hashes', () => {
      assert.equal(hashSC.hash(objects.d), hashSC.hash(objects.e));
    });
  });
  describe('#hash() on complex objects: [sort=true, coerce=true]', () => {
    it('should return equal hashes', () => {
      assert.equal(hashSC.hash(objects.f), hashSC.hash(objects.g));
    });
  });

  describe('#sortObject() on multitype array: [sort=true, coerce=true]', () => {
    it('should return sorted array', () => {
      assert.equal(hashSC.sortObject(objects.e), '[0,1,2,3,4]');
    });
  });

  describe('#hash() on complex objects: [sort=true, coerce=true]', () => {
    it('should return equal hashes', () => {
      assert.equal(hashSC.hash(objects.h), hashSC.hash(objects.i));
    });
  });
});<commit_msg>update tests to fit node-0.10.x<commit_after>/**
 * Created on 8/23/16.
 */
'use strict';


var hash = require('../hash2');
var assert = require('chai').assert;

var hashSC = hash();
var hashS = hash({coerce: false});
var hashC = hash({sort: false});

var libName = 'node-object-hash-v2';

var objects = {
  a: {
    b: 1,
    c: 3,
    a: 4,
    f: 0
  },
  b: {
    c: 3,
    b: 1,
    f: 0,
    a: 4
  },
  c: {
    c: '3',
    b: 1,
    f: '0',
    a: 4
  },
  d: [4, 3, 0, 2, 1],
  e: [2, '4', '3', false, true],
  f: {
    a: [{c: 2, a: 1, b: {a: 3, c: 2, b: 0}}],
    b: [1, 'a', {}, null],
  },
  g: {
    b: ['a', 1, {}, undefined],
    a: [{c: '2', b: {b: false, c: 2, a: '3'}, a: true}]
  },
  h: {
    type: 'ui',
    key: {
      code: 'BLA'
    }
  },
  i: {
    type: 'ui',
    key: {
      code: 'BLA'
    }
  }
};

describe(libName, function () {
  describe('#hash() on objects: [sort=true, coerce=true]', function () {
    it('should return equal hashes', function () {
      assert.equal(hashSC.hash(objects.a), hashSC.hash(objects.c));
    });
  });
  describe('#hash() on objects: [sort=true, coerce=false]', function () {
    it('should return equal hashes', function () {
      assert.equal(hashS.hash(objects.a), hashS.hash(objects.b));
    });
  });
  describe('#hash() on objects: [sort=false, coerce=true]', function () {
    it('should return equal hashes', function () {
      assert.equal(hashC.hash(objects.c), hashC.hash(objects.b));
    });
  });
  describe('#hash() on arrays: [sort=true, coerce=true]', function () {
    it('should return equal hashes', function () {
      assert.equal(hashSC.hash(objects.d), hashSC.hash(objects.e));
    });
  });
  describe('#hash() on complex objects: [sort=true, coerce=true]', function () {
    it('should return equal hashes', function () {
      assert.equal(hashSC.hash(objects.f), hashSC.hash(objects.g));
    });
  });

  describe('#sortObject() on multitype array: [sort=true, coerce=true]', function () {
    it('should return sorted array', function () {
      assert.equal(hashSC.sortObject(objects.e), '[0,1,2,3,4]');
    });
  });

  describe('#hash() on complex objects: [sort=true, coerce=true]', function () {
    it('should return equal hashes', function () {
      assert.equal(hashSC.hash(objects.h), hashSC.hash(objects.i));
    });
  });
});
{'fraction_non_alphanumeric': 0.23476545374835597, 'fraction_numerical': 0.019070583077597545, 'mean_word_length': 2.796173044925125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '5953079', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1760, 'n_words': 407}