你如何对 geddy 控制器进行单元测试?这是我要测试的示例。
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;
如何对控制器方法进行单元测试?如何模拟请求和响应?
谢谢你。