mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 00:15:46 +01:00
more user tests
This commit is contained in:
@@ -39,12 +39,17 @@ userController.getUserByEmail = function (req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function byType(type, req, res, next) {
|
function byType(type, req, res, next) {
|
||||||
userController.getUserDataByField(req.uid, type, req.params[type], function (err, data) {
|
async.waterfall([
|
||||||
if (err || !data) {
|
function (next) {
|
||||||
return next(err);
|
userController.getUserDataByField(req.uid, type, req.params[type], next);
|
||||||
|
},
|
||||||
|
function (data, next) {
|
||||||
|
if (!data) {
|
||||||
|
return next();
|
||||||
}
|
}
|
||||||
res.json(data);
|
res.json(data);
|
||||||
});
|
}
|
||||||
|
], next);
|
||||||
}
|
}
|
||||||
|
|
||||||
userController.getUserDataByField = function (callerUid, field, fieldValue, callback) {
|
userController.getUserDataByField = function (callerUid, field, fieldValue, callback) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ describe('Controllers', function () {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
user: function (next) {
|
user: function (next) {
|
||||||
user.create({ username: 'foo', password: 'barbar' }, next);
|
user.create({ username: 'foo', password: 'barbar', email: 'foo@test.com' }, next);
|
||||||
},
|
},
|
||||||
navigation: function (next) {
|
navigation: function (next) {
|
||||||
var navigation = require('../src/navigation/admin');
|
var navigation = require('../src/navigation/admin');
|
||||||
@@ -911,6 +911,42 @@ describe('Controllers', function () {
|
|||||||
},
|
},
|
||||||
], done);
|
], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should 404 if user does not exist', function (done) {
|
||||||
|
request(nconf.get('url') + '/api/user/email/doesnotexist', function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 404);
|
||||||
|
assert(body);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should load user by uid', function (done) {
|
||||||
|
request(nconf.get('url') + '/api/user/uid/' + fooUid, function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert(body);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should load user by username', function (done) {
|
||||||
|
request(nconf.get('url') + '/api/user/username/foo', function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert(body);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should load user by email', function (done) {
|
||||||
|
request(nconf.get('url') + '/api/user/email/foo@test.com', function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert(body);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('account follow page', function () {
|
describe('account follow page', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user