From 28331389a6fc26e95d04841591f5db1ad74d973d Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 13 Aug 2016 01:20:19 +0300 Subject: [PATCH] added getTopicWithPosts test --- tests/topics.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/topics.js b/tests/topics.js index dcf7f1067e..7103b32689 100644 --- a/tests/topics.js +++ b/tests/topics.js @@ -132,7 +132,7 @@ describe('Topic\'s', function() { var newTopic; var newPost; - beforeEach(function(done) { + before(function(done) { topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function(err, result) { newTopic = result.topicData; newPost = result.postData; @@ -145,6 +145,28 @@ describe('Topic\'s', function() { topics.getTopicData(newTopic.tid, done); }); }); + + describe('.getTopicWithPosts', function() { + it('should get a topic with posts and other data', function(done) { + topics.getTopicData(newTopic.tid, function(err, topicData) { + if (err) { + return done(err); + } + topics.getTopicWithPosts(topicData, 'tid:' + newTopic.tid + ':posts', topic.userId, 0, -1, false, function(err, data) { + if (err) { + return done(err); + } + assert(data); + assert.equal(data.category.cid, topic.categoryId); + assert.equal(data.unreplied, true); + assert.equal(data.deleted, false); + assert.equal(data.locked, false); + assert.equal(data.pinned, false); + done(); + }); + }); + }); + }); }); describe('Title escaping', function() {