mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
feat: more tests for ensuring downvoted posts are added to the :votes zset
This commit is contained in:
@@ -1315,6 +1315,15 @@ describe('Controllers', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should load /user/foo/controversial', (done) => {
|
||||||
|
request(`${nconf.get('url')}/api/user/foo/controversial`, (err, res, body) => {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 200);
|
||||||
|
assert(body);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should load /user/foo/watched', (done) => {
|
it('should load /user/foo/watched', (done) => {
|
||||||
request(`${nconf.get('url')}/api/user/foo/watched`, { jar: jar }, (err, res, body) => {
|
request(`${nconf.get('url')}/api/user/foo/watched`, { jar: jar }, (err, res, body) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|||||||
@@ -193,6 +193,14 @@ describe('Post\'s', () => {
|
|||||||
assert.equal(data.downvoted, false);
|
assert.equal(data.downvoted, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add the pid to the :votes sorted set for that user', async () => {
|
||||||
|
const cid = await posts.getCidByPid(postData.pid);
|
||||||
|
const { uid, pid } = postData;
|
||||||
|
|
||||||
|
const score = await db.sortedSetScore(`cid:${cid}:uid:${uid}:pids:votes`, pid);
|
||||||
|
assert.strictEqual(score, 1);
|
||||||
|
});
|
||||||
|
|
||||||
it('should get voters', (done) => {
|
it('should get voters', (done) => {
|
||||||
socketPosts.getVoters({ uid: globalModUid }, { pid: postData.pid, cid: cid }, (err, data) => {
|
socketPosts.getVoters({ uid: globalModUid }, { pid: postData.pid, cid: cid }, (err, data) => {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
@@ -235,6 +243,14 @@ describe('Post\'s', () => {
|
|||||||
assert.equal(data.downvoted, true);
|
assert.equal(data.downvoted, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add the pid to the :votes sorted set for that user', async () => {
|
||||||
|
const cid = await posts.getCidByPid(postData.pid);
|
||||||
|
const { uid, pid } = postData;
|
||||||
|
|
||||||
|
const score = await db.sortedSetScore(`cid:${cid}:uid:${uid}:pids:votes`, pid);
|
||||||
|
assert.strictEqual(score, -1);
|
||||||
|
});
|
||||||
|
|
||||||
it('should prevent downvoting more than total daily limit', async () => {
|
it('should prevent downvoting more than total daily limit', async () => {
|
||||||
const oldValue = meta.config.downvotesPerDay;
|
const oldValue = meta.config.downvotesPerDay;
|
||||||
meta.config.downvotesPerDay = 1;
|
meta.config.downvotesPerDay = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user