Node.js based forum software built for the modern web
feat: more tests for ensuring downvoted posts are added to the :votes zset
Julian Lam1b8eeaf840fb
diff --git a/test/controllers.js b/test/controllers.jsindex 3669dd32e1..bb4aec7688 100644--- a/test/controllers.js+++ b/test/controllers.js@@ -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) => {request(`${nconf.get('url')}/api/user/foo/watched`, { jar: jar }, (err, res, body) => {assert.ifError(err);diff --git a/test/posts.js b/test/posts.jsindex 5680a2fd44..8c2a7d3a5c 100644--- a/test/posts.js+++ b/test/posts.js@@ -193,6 +193,14 @@ describe('Post\'s', () => {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) => {socketPosts.getVoters({ uid: globalModUid }, { pid: postData.pid, cid: cid }, (err, data) => {assert.ifError(err);@@ -235,6 +243,14 @@ describe('Post\'s', () => {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 () => {const oldValue = meta.config.downvotesPerDay;meta.config.downvotesPerDay = 1;