follow tests

This commit is contained in:
barisusakli
2016-12-01 18:36:43 +03:00
parent 5cf8006640
commit c3980d0c2e
2 changed files with 58 additions and 21 deletions

View File

@@ -785,7 +785,47 @@ describe('Controllers', function () {
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) {