var _ = require('lodash');
var assert = require('assert');

var utils = require('../lib/utils');

function hookMaker(name) {
  return function() {
    return utils.hookObject(name, arguments);
  };
}

describe('hook utilities', function() {
  it('.hookObject', function() {
    // find
    assert.deepEqual(hookMaker('find')({ some: 'thing' }, _.noop), {
      params: { some: 'thing' },
      method: 'find',
      callback: _.noop
    });

    // get
    assert.deepEqual(hookMaker('get')(1, { some: 'thing' }, _.noop), {
      id: 1,
      params: { some: 'thing' },
      method: 'get',
      callback: _.noop
    });

    // remove
    assert.deepEqual(hookMaker('remove')(1, { some: 'thing' }, _.noop), {
      id: 1,
      params: { some: 'thing' },
      method: 'remove',
      callback: _.noop
    });

    // create
    assert.deepEqual(hookMaker('create')({ my: 'data' }, { some: 'thing' }, _.noop), {
      data: { my: 'data' },
      params: { some: 'thing' },
      method: 'create',
      callback: _.noop
    });

    // update
    assert.deepEqual(hookMaker('update')(2, { my: 'data' }, { some: 'thing' }, _.noop), {
      id: 2,
      data: { my: 'data' },
      params: { some: 'thing' },
      method: 'update',
      callback: _.noop
    });

    // patch
    assert.deepEqual(hookMaker('patch')(2, { my: 'data' }, { some: 'thing' }, _.noop), {
      id: 2,
      data: { my: 'data' },
      params: { some: 'thing' },
      method: 'patch',
      callback: _.noop
    });
  });

  it('.makeArguments', function() {
    var args = utils.makeArguments({
      id: 2,
      data: { my: 'data' },
      params: { some: 'thing' },
      method: 'update',
      callback: _.noop
    });

    assert.deepEqual(args, [2, { my: 'data' }, { some: 'thing' }, _.noop]);

    args = utils.makeArguments({
      params: { some: 'thing' },
      method: 'find',
      callback: _.noop
    });

    assert.deepEqual(args, [
      { some: 'thing' },
      _.noop
    ]);
  });
});

@@ -1771,24 +1771,264 @@
  _.noop%5D);%0A%0A
+    args = utils.makeArguments(%7B%0A      id: 0,%0A      data: %7B my: 'data' %7D,%0A      params: %7B some: 'thing' %7D,%0A      method: 'update',%0A      callback: _.noop%0A    %7D);%0A%0A    assert.deepEqual(args, %5B0, %7B my: 'data' %7D, %7B some: 'thing' %7D, _.noop%5D);%0A%0A
     args = u

Test for .makeArguments id check.