mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
follow tests
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
plugins = require('../plugins'),
|
var plugins = require('../plugins');
|
||||||
db = require('../database');
|
var db = require('../database');
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
|
|
||||||
@@ -73,25 +73,22 @@ module.exports = function (User) {
|
|||||||
if (!parseInt(uid, 10)) {
|
if (!parseInt(uid, 10)) {
|
||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
|
async.waterfall([
|
||||||
db.getSortedSetRevRange(type + ':' + uid, start, stop, function (err, uids) {
|
function (next) {
|
||||||
if (err) {
|
db.getSortedSetRevRange(type + ':' + uid, start, stop, next);
|
||||||
return callback(err);
|
},
|
||||||
}
|
function (uids, next) {
|
||||||
|
|
||||||
plugins.fireHook('filter:user.' + type, {
|
plugins.fireHook('filter:user.' + type, {
|
||||||
uids: uids,
|
uids: uids,
|
||||||
uid: uid,
|
uid: uid,
|
||||||
start: start,
|
start: start,
|
||||||
stop: stop
|
stop: stop
|
||||||
}, function (err, data) {
|
}, next);
|
||||||
if (err) {
|
},
|
||||||
return callback(err);
|
function (data, next) {
|
||||||
|
User.getUsers(data.uids, uid, next);
|
||||||
}
|
}
|
||||||
|
], callback);
|
||||||
User.getUsers(data.uids, uid, callback);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
User.isFollowing = function (uid, theirid, callback) {
|
User.isFollowing = function (uid, theirid, callback) {
|
||||||
|
|||||||
@@ -785,7 +785,47 @@ describe('Controllers', function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('account follow page', function () {
|
||||||
|
var uid;
|
||||||
|
before(function (done) {
|
||||||
|
user.create({username: 'follower'}, function (err, _uid) {
|
||||||
|
assert.ifError(err);
|
||||||
|
uid = _uid;
|
||||||
|
user.follow(uid, fooUid, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get followers page', function (done) {
|
||||||
|
request(nconf.get('url') + '/api/user/foo/followers', {json: true}, function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert.equal(body.users[0].username, 'follower');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get following page', function (done) {
|
||||||
|
request(nconf.get('url') + '/api/user/follower/following', {json: true}, function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert.equal(body.users[0].username, 'foo');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return empty after unfollow', function (done ) {
|
||||||
|
user.unfollow(uid, fooUid, function (err) {
|
||||||
|
assert.ifError(err);
|
||||||
|
request(nconf.get('url') + '/api/user/foo/followers', {json: true}, function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert.equal(body.users.length, 0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function (done) {
|
after(function (done) {
|
||||||
|
|||||||
Reference in New Issue
Block a user