/**
 * 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));
    });
  });
});

@@ -798,21 +798,27 @@
 ibName, 
-() =%3E
+function ()
  %7B%0A  des
@@ -863,37 +863,43 @@
  coerce=true%5D', 
-() =%3E
+function ()
  %7B%0A    it('shoul
@@ -914,37 +914,43 @@
  equal hashes', 
-() =%3E
+function ()
  %7B%0A      assert.
@@ -1073,30 +1073,36 @@
 rce=false%5D',
+ function
  ()
- =%3E
  %7B%0A    it('s
@@ -1121,37 +1121,43 @@
  equal hashes', 
-() =%3E
+function ()
  %7B%0A      assert.
@@ -1275,37 +1275,43 @@
  coerce=true%5D', 
-() =%3E
+function ()
  %7B%0A    it('shoul
@@ -1326,37 +1326,43 @@
  equal hashes', 
-() =%3E
+function ()
  %7B%0A      assert.
@@ -1478,37 +1478,43 @@
  coerce=true%5D', 
-() =%3E
+function ()
  %7B%0A    it('shoul
@@ -1529,37 +1529,43 @@
  equal hashes', 
-() =%3E
+function ()
  %7B%0A      assert.
@@ -1692,37 +1692,43 @@
  coerce=true%5D', 
-() =%3E
+function ()
  %7B%0A    it('shoul
@@ -1743,37 +1743,43 @@
  equal hashes', 
-() =%3E
+function ()
  %7B%0A      assert.
@@ -1913,37 +1913,43 @@
  coerce=true%5D', 
-() =%3E
+function ()
  %7B%0A    it('shoul
@@ -1972,21 +1972,27 @@
 array', 
-() =%3E
+function ()
  %7B%0A     
@@ -2133,21 +2133,27 @@
 true%5D', 
-() =%3E
+function ()
  %7B%0A    i
@@ -2188,13 +2188,19 @@
 s', 
-() =%3E
+function ()
  %7B%0A 

update tests to fit node-0.10.x