Node.js based forum software built for the modern web
add test for posts.getReplies
Ben Lubar661bdc83117a
diff --git a/test/topics.js b/test/topics.jsindex 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]]');