mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 19:11:22 +01:00
add test for posts.getReplies
This commit is contained in:
@@ -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]]');
|
||||
|
||||
Reference in New Issue
Block a user