From 031ffe491e0f17460f9ff13ee54d575d55c492a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 12 May 2023 10:22:13 -0400 Subject: [PATCH] test: add back missing tests --- test/posts.js | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/test/posts.js b/test/posts.js index 68aeae7338..3adedb766b 100644 --- a/test/posts.js +++ b/test/posts.js @@ -23,6 +23,7 @@ const apiTopics = require('../src/api/topics'); const meta = require('../src/meta'); const file = require('../src/file'); const helpers = require('./helpers'); +const utils = require('../src/utils'); describe('Post\'s', () => { let voterUid; @@ -865,17 +866,47 @@ describe('Post\'s', () => { assert(postData); }); - it('shold get post summary', async () => { + it('should get post summary', async () => { const summary = await apiPosts.getSummary({ uid: voterUid }, { pid }); assert(summary); }); - it('should get post category', (done) => { - socketPosts.getCategory({ uid: voterUid }, pid, (err, postCid) => { - assert.ifError(err); - assert.equal(cid, postCid); - done(); + it('should get raw post content', async () => { + const postContent = await socketPosts.getRawPost({ uid: voterUid }, pid); + assert.equal(postContent, 'raw content'); + }); + + it('should get post summary by index', async () => { + const summary = await socketPosts.getPostSummaryByIndex({ uid: voterUid }, { + index: 1, + tid: topicData.tid, + }); + assert(summary); + }); + + it('should get post timestamp by index', async () => { + const timestamp = await socketPosts.getPostTimestampByIndex({ uid: voterUid }, { + index: 1, + tid: topicData.tid, + }); + assert(utils.isNumber(timestamp)); + }); + + it('should get post timestamp by index', async () => { + const summary = await socketPosts.getPostSummaryByPid({ uid: voterUid }, { + pid: pid, }); + assert(summary); + }); + + it('should get post category', async () => { + const postCid = await socketPosts.getCategory({ uid: voterUid }, pid); + assert.equal(cid, postCid); + }); + + it('should get pid index', async () => { + const index = await socketPosts.getPidIndex({ uid: voterUid }, { pid: pid, tid: topicData.tid, topicPostSort: 'oldest_to_newest' }); + assert.equal(index, 4); }); it('should get pid index', async () => {