From 661bdc83117adf27ecde5224ec375e4e3291f929 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Fri, 28 Oct 2016 09:18:09 -0500 Subject: [PATCH] add test for posts.getReplies --- test/topics.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/topics.js b/test/topics.js index 135ec5de8c..2abe344102 100644 --- a/test/topics.js +++ b/test/topics.js @@ -2,7 +2,7 @@ /*global require, before, beforeEach, after*/ var async = require('async'); -var assert = require('assert'); +var assert = require('assert'); var validator = require('validator'); var nconf = require('nconf'); @@ -11,6 +11,7 @@ var topics = require('../src/topics'); var categories = require('../src/categories'); var User = require('../src/user'); var groups = require('../src/groups'); +var socketPosts = require('../src/socket.io/posts'); describe('Topic\'s', function () { var topic; @@ -120,6 +121,24 @@ describe('Topic\'s', function () { }); }); + it('should handle direct replies', function (done) { + topics.reply({uid: topic.userId, content: 'test reply', tid: newTopic.tid, toPid: newPost.pid}, function (err, result) { + assert.equal(err, null, 'was created with error'); + assert.ok(result); + + socketPosts.getReplies({uid: 0}, newPost.pid, function (err, response) { + assert.equal(err, null, 'posts.getReplies returned error'); + + assert.ok(response); + + assert.equal(response.posts.length, 1, 'should have 1 result'); + assert.equal(response.posts[0].pid, result.pid, 'result should be the reply we added'); + + done(); + }); + }); + }); + it('should fail to create new reply with invalid user id', function (done) { topics.reply({uid: null, content: 'test post', tid: newTopic.tid}, function (err) { assert.equal(err.message, '[[error:no-privileges]]');