/**
 * @fileOverview Testers common library.
 */

var sinon = require('sinon');
var sinonChai = require('sinon-chai');
var chai = require('chai');
chai.use(sinonChai);

var tester = module.exports = {};

function noop () {}

/**
 * Returns A stub controller for crude.
 *
 * @return {Object} A stub controller for crude.
 */
tester.controller = function() {
  return {
    create: sinon.mock(),
    read: sinon.mock(),
    readLimit: sinon.mock(),
    readOne: sinon.mock(),
    update: sinon.mock(),
    count: sinon.mock(),
    delete: sinon.mock(),
  };
};

/**
 * Return express Request / Response objects.
 *
 * @return {Object} Req Res mocks.
 */
tester.reqres = function() {
  var reqres = {
    req: {
      query: {},
      body: {},
      params: {},
    },
    res: {
      status: function() {return reqres.res;},
      json: noop,
    },
  };

  return reqres;
};

@@ -201,29 +201,8 @@
 %7D;%0A%0A
-function noop () %7B%7D%0A%0A
 /**%0A
@@ -332,24 +332,67 @@
 n() %7B%0A  
-return %7B
+var item = %7Ba: 1%7D;%0A  var ctrl = %7B%0A    __item: item,
 %0A    cre
@@ -400,32 +400,46 @@
 te: sinon.mock()
+.returns(item)
 ,%0A    read: sino
@@ -438,32 +438,48 @@
 ad: sinon.mock()
+.returns(%5Bitem%5D)
 ,%0A    readLimit:
@@ -487,24 +487,40 @@
 sinon.mock()
+.returns(%5Bitem%5D)
 ,%0A    readOn
@@ -530,24 +530,38 @@
 sinon.mock()
+.returns(item)
 ,%0A    update
@@ -570,24 +570,38 @@
 sinon.mock()
+.returns(item)
 ,%0A    count:
@@ -609,24 +609,35 @@
 sinon.mock()
+.returns(1)
 ,%0A    delete
@@ -656,16 +656,32 @@
 (),%0A  %7D;
+%0A%0A  return ctrl;
 %0A%7D;%0A%0A/**
@@ -885,97 +885,258 @@
     
-%7D,%0A    res: %7B%0A      status: function() %7Breturn reqres.res;%7D,%0A      json: noop,%0A    %7D,%0A  %7D
+  url: 'http://localhost/',%0A      app: %7B%0A        settings: %7B%0A          port: 80,%0A        %7D,%0A      %7D,%0A    %7D,%0A    res: %7B%0A      status: sinon.mock(),%0A      set: sinon.mock(),%0A      json: sinon.mock(),%0A    %7D,%0A  %7D;%0A%0A  reqres.res.status.returns(reqres.res)
 ;%0A%0A 

work on tester lib, expand reqres