how you unit test geddy controller? this is an example i want to test.
var assert = require('assert')
, tests
, controller = geddy.controller.create('Users');
tests = {
'test user controller, add new user': function (next) {
var user = User.create({username: 'hbinduni',
password: 'MyPassword!',
confirmPassword: 'MyPassword!',
familyName: 'binduni',
givenName: 'binduni',
email: 'hbinduni@email.com'});
//need to unit test controller.add here
//how to mock req, resp?
controller.add(req, resp, user);
assert.equal(out, null);
next();
}
};
module.exports = tests;
how can i do unit test on controller method? how to mock request and response?
thank you.