From 8691256a67a9e4207275a0b537eb7b77a2ec43cf Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 5 Dec 2016 16:30:30 +0300 Subject: [PATCH] fix post move test --- test/posts.js | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/test/posts.js b/test/posts.js index eaf2b0b373..1ddbd83399 100644 --- a/test/posts.js +++ b/test/posts.js @@ -378,18 +378,44 @@ describe('Post\'s', function () { }, function (err, data) { assert.ifError(err); replyPid = data.pid; - socketPosts.movePost({uid: globalModUid}, {pid: replyPid, tid: moveTid}, next); + next(); }); - }, - function (next) { - posts.getPostField(replyPid, 'tid', next); - }, - function (tid, next) { - assert(tid, moveTid); - next(); } ], done); }); + + it('should error if uid is not logged in', function (done) { + socketPosts.movePost({uid: 0}, {}, function (err) { + assert.equal(err.message, '[[error:not-logged-in]]'); + done(); + }); + }); + + it('should error if data is invalid', function (done) { + socketPosts.movePost({uid: globalModUid}, {}, function (err) { + assert.equal(err.message, '[[error:invalid-data]]'); + done(); + }); + }); + + it('should error if user does not have move privilege', function (done) { + socketPosts.movePost({uid: voterUid}, {pid: replyPid, tid: moveTid}, function (err) { + assert.equal(err.message, '[[error:no-privileges]]'); + done(); + }); + }); + + + it('should move a post', function (done) { + socketPosts.movePost({uid: globalModUid}, {pid: replyPid, tid: moveTid}, function (err) { + assert.ifError(err); + posts.getPostField(replyPid, 'tid', function (err, tid) { + assert.ifError(err); + assert(tid, moveTid); + done(); + }); + }); + }); }); describe('flagging a post', function () {