'use strict';

var transformPerSuffixes = require('./index');
var assert = require('assert');

describe('transform-per-suffixes', function() {

  describe('transformPerSuffixes()', function() {

    it('should work for a simple object', function() {
      assert.deepEqual(transformPerSuffixes([{
        value: '_id',
        transform:  function(n) { return Number(n) },
      }, {
        value: '_date',
        transform: function(d) { return new Date(d) },
      }], {
        _id: '1664',
        creation_date: '2015-11-28T16:22:47.552Z',
        value: 'Hey!',
      }), {
        _id: 1664,
        creation_date: new Date('2015-11-28T16:22:47.552Z'),
        value: 'Hey!',
      });
    });

    it('should work for a simple object with array', function() {
      assert.deepEqual(transformPerSuffixes([{
        value: '_id',
        transform:  function(n) { return Number(n) },
      }, {
        value: '_date',
        transform: function(d) { return new Date(d) },
      }], {
        objects: [{
          _id: '1664',
          creation_date: '2015-11-28T16:22:47.552Z',
          value: 'Hey!',
        }, {
          _id: '1664',
          creation_date: '2015-11-28T16:22:47.552Z',
          value: 'Hey!',
        }],
      }), {
        objects: [{
          _id: 1664,
          creation_date: new Date('2015-11-28T16:22:47.552Z'),
          value: 'Hey!',
        }, {
          _id: 1664,
          creation_date: new Date('2015-11-28T16:22:47.552Z'),
          value: 'Hey!',
        }],
      });
    });

    it('should work for a recursive object', function() {
      assert.deepEqual(transformPerSuffixes([{
        value: '_id',
        transform:  function(n) { return Number(n) },
      }, {
        value: '_date',
        transform: function(d) { return new Date(d) },
      }], {
        _id: '1664',
        creation_date: '2015-11-28T16:22:47.552Z',
        value: {
          _id: '1664',
          creation_date: '2015-11-28T16:22:47.552Z',
          value: {
            _id: '1664',
            creation_date: '2015-11-28T16:22:47.552Z',
            value: 'Hey!',
          },
        },
      }), {
        _id: 1664,
        creation_date: new Date('2015-11-28T16:22:47.552Z'),
        value: {
          _id: 1664,
          creation_date: new Date('2015-11-28T16:22:47.552Z'),
          value: {
            _id: 1664,
            creation_date: new Date('2015-11-28T16:22:47.552Z'),
            value: 'Hey!',
          },
        },
      });
    });

  });

});

@@ -322,33 +322,32 @@
       transform:
- 
  function(n) %7B r
@@ -353,32 +353,33 @@
 return Number(n)
+;
  %7D,%0A      %7D, %7B%0A 
@@ -444,32 +444,33 @@
 turn new Date(d)
+;
  %7D,%0A      %7D%5D, %7B%0A
@@ -843,33 +843,32 @@
       transform:
- 
  function(n) %7B r
@@ -874,32 +874,33 @@
 return Number(n)
+;
  %7D,%0A      %7D, %7B%0A 
@@ -965,32 +965,33 @@
 turn new Date(d)
+;
  %7D,%0A      %7D%5D, %7B%0A
@@ -1676,17 +1676,16 @@
 ansform:
- 
  functio
@@ -1707,16 +1707,17 @@
 umber(n)
+;
  %7D,%0A    
@@ -1798,16 +1798,17 @@
  Date(d)
+;
  %7D,%0A    

Fix linter errors