ESlint object-curly-spacing

This commit is contained in:
Peter Jaszkowiak
2017-02-18 12:30:49 -07:00
parent 1493afee2a
commit 896c8c7343
207 changed files with 971 additions and 971 deletions

View File

@@ -19,7 +19,7 @@ describe('Topic\'s', function () {
before(function (done) {
groups.resetCache();
User.create({username: 'admin'}, function (err, uid) {
User.create({ username: 'admin' }, function (err, uid) {
if (err) {
return done(err);
}
@@ -49,7 +49,7 @@ describe('Topic\'s', function () {
describe('.post', function () {
it('should create a new topic with proper parameters', function (done) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) {
assert.equal(err, null, 'was created with error');
assert.ok(result);
@@ -58,28 +58,28 @@ describe('Topic\'s', function () {
});
it('should fail to create new topic with invalid user id', function (done) {
topics.post({uid: null, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err) {
topics.post({ uid: null, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err) {
assert.equal(err.message, '[[error:no-privileges]]');
done();
});
});
it('should fail to create new topic with empty title', function (done) {
topics.post({uid: topic.userId, title: '', content: topic.content, cid: topic.categoryId}, function (err) {
topics.post({ uid: topic.userId, title: '', content: topic.content, cid: topic.categoryId }, function (err) {
assert.ok(err);
done();
});
});
it('should fail to create new topic with empty content', function (done) {
topics.post({uid: topic.userId, title: topic.title, content: '', cid: topic.categoryId}, function (err) {
topics.post({ uid: topic.userId, title: topic.title, content: '', cid: topic.categoryId }, function (err) {
assert.ok(err);
done();
});
});
it('should fail to create new topic with non-existant category id', function (done) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: 99}, function (err) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: 99 }, function (err) {
assert.equal(err.message, '[[error:no-category]]', 'received no error');
done();
});
@@ -91,7 +91,7 @@ describe('Topic\'s', function () {
var newPost;
before(function (done) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) {
if (err) {
return done(err);
}
@@ -103,7 +103,7 @@ describe('Topic\'s', function () {
});
it('should create a new reply with proper parameters', function (done) {
topics.reply({uid: topic.userId, content: 'test post', tid: newTopic.tid}, function (err, result) {
topics.reply({ uid: topic.userId, content: 'test post', tid: newTopic.tid }, function (err, result) {
assert.equal(err, null, 'was created with error');
assert.ok(result);
@@ -112,11 +112,11 @@ 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) {
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, postData) {
socketPosts.getReplies({ uid: 0 }, newPost.pid, function (err, postData) {
assert.equal(err, null, 'posts.getReplies returned error');
assert.ok(postData);
@@ -130,28 +130,28 @@ describe('Topic\'s', function () {
});
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) {
topics.reply({ uid: null, content: 'test post', tid: newTopic.tid }, function (err) {
assert.equal(err.message, '[[error:no-privileges]]');
done();
});
});
it('should fail to create new reply with empty content', function (done) {
topics.reply({uid: topic.userId, content: '', tid: newTopic.tid}, function (err) {
topics.reply({ uid: topic.userId, content: '', tid: newTopic.tid }, function (err) {
assert.ok(err);
done();
});
});
it('should fail to create new reply with invalid topic id', function (done) {
topics.reply({uid: null, content: 'test post', tid: 99}, function (err) {
topics.reply({ uid: null, content: 'test post', tid: 99 }, function (err) {
assert.equal(err.message, '[[error:no-topic]]');
done();
});
});
it('should fail to create new reply with invalid toPid', function (done) {
topics.reply({uid: topic.userId, content: 'test post', tid: newTopic.tid, toPid: '"onmouseover=alert(1);//'}, function (err) {
topics.reply({ uid: topic.userId, content: 'test post', tid: newTopic.tid, toPid: '"onmouseover=alert(1);//' }, function (err) {
assert.equal(err.message, '[[error:invalid-pid]]');
done();
});
@@ -163,7 +163,7 @@ describe('Topic\'s', function () {
var newPost;
before(function (done) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) {
if (err) {
return done(err);
}
@@ -207,7 +207,7 @@ describe('Topic\'s', function () {
it('should properly escape topic title', function (done) {
var title = '"<script>alert(\'ok1\');</script> new topic test';
var titleEscaped = validator.escape(title);
topics.post({uid: topic.userId, title: title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: title, content: topic.content, cid: topic.categoryId }, function (err, result) {
assert.ifError(err);
topics.getTopicData(result.topicData.tid, function (err, topicData) {
assert.ifError(err);
@@ -230,14 +230,14 @@ describe('Topic\'s', function () {
groups.join('administrators', adminUid, next);
},
function (next) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) {
assert.ifError(err);
newTopic = result.topicData;
next();
});
},
function (next) {
User.create({username: 'topicFollower', password: '123456'}, next);
User.create({ username: 'topicFollower', password: '123456' }, next);
},
function (_uid, next) {
followerUid = _uid;
@@ -259,7 +259,7 @@ describe('Topic\'s', function () {
});
it('should load topic tools', function (done) {
socketTopics.loadTopicTools({uid: 1}, {tid: newTopic.tid}, function (err, data) {
socketTopics.loadTopicTools({ uid: 1 }, { tid: newTopic.tid }, function (err, data) {
assert.ifError(err);
assert(data);
done();
@@ -267,21 +267,21 @@ describe('Topic\'s', function () {
});
it('should delete the topic', function (done) {
socketTopics.delete({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.delete({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
done();
});
});
it('should restore the topic', function (done) {
socketTopics.restore({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.restore({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
done();
});
});
it('should lock topic', function (done) {
socketTopics.lock({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.lock({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
topics.isLocked(newTopic.tid, function (err, isLocked) {
assert.ifError(err);
@@ -292,7 +292,7 @@ describe('Topic\'s', function () {
});
it('should unlock topic', function (done) {
socketTopics.unlock({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.unlock({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
topics.isLocked(newTopic.tid, function (err, isLocked) {
assert.ifError(err);
@@ -303,7 +303,7 @@ describe('Topic\'s', function () {
});
it('should pin topic', function (done) {
socketTopics.pin({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.pin({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
db.getObjectField('topic:' + newTopic.tid, 'pinned', function (err, pinned) {
assert.ifError(err);
@@ -314,7 +314,7 @@ describe('Topic\'s', function () {
});
it('should unpin topic', function (done) {
socketTopics.unpin({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.unpin({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
db.getObjectField('topic:' + newTopic.tid, 'pinned', function (err, pinned) {
assert.ifError(err);
@@ -325,7 +325,7 @@ describe('Topic\'s', function () {
});
it('should move all topics', function (done) {
socketTopics.moveAll({uid: 1}, {cid: moveCid, currentCid: categoryObj.cid}, function (err) {
socketTopics.moveAll({ uid: 1 }, { cid: moveCid, currentCid: categoryObj.cid }, function (err) {
assert.ifError(err);
topics.getTopicField(newTopic.tid, 'cid', function (err, cid) {
assert.ifError(err);
@@ -336,7 +336,7 @@ describe('Topic\'s', function () {
});
it('should move a topic', function (done) {
socketTopics.move({uid: 1}, {cid: categoryObj.cid, tids: [newTopic.tid]}, function (err) {
socketTopics.move({ uid: 1 }, { cid: categoryObj.cid, tids: [newTopic.tid] }, function (err) {
assert.ifError(err);
topics.getTopicField(newTopic.tid, 'cid', function (err, cid) {
assert.ifError(err);
@@ -347,7 +347,7 @@ describe('Topic\'s', function () {
});
it('should purge the topic', function (done) {
socketTopics.purge({uid: 1}, {tids: [newTopic.tid], cid: categoryObj.cid}, function (err) {
socketTopics.purge({ uid: 1 }, { tids: [newTopic.tid], cid: categoryObj.cid }, function (err) {
assert.ifError(err);
db.isSortedSetMember('uid:' + followerUid + ':followed_tids', newTopic.tid, function (err, isMember) {
assert.ifError(err);
@@ -399,28 +399,28 @@ describe('Topic\'s', function () {
var socketTopics = require('../src/socket.io/topics');
it('should error with invalid data', function (done) {
socketTopics.orderPinnedTopics({uid: adminUid}, null, function (err) {
socketTopics.orderPinnedTopics({ uid: adminUid }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should error with invalid data', function (done) {
socketTopics.orderPinnedTopics({uid: adminUid}, [null, null], function (err) {
socketTopics.orderPinnedTopics({ uid: adminUid }, [null, null], function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should error with unprivileged user', function (done) {
socketTopics.orderPinnedTopics({uid: 0}, [{tid: tid1}, {tid: tid2}], function (err) {
socketTopics.orderPinnedTopics({ uid: 0 }, [{ tid: tid1 }, { tid: tid2 }], function (err) {
assert.equal(err.message, '[[error:no-privileges]]');
done();
});
});
it('should not do anything if topics are not pinned', function (done) {
socketTopics.orderPinnedTopics({uid: adminUid}, [{tid: tid3}], function (err) {
socketTopics.orderPinnedTopics({ uid: adminUid }, [{ tid: tid3 }], function (err) {
assert.ifError(err);
db.isSortedSetMember('cid:' + topic.categoryId + ':tids:pinned', tid3, function (err, isMember) {
assert.ifError(err);
@@ -435,7 +435,7 @@ describe('Topic\'s', function () {
assert.ifError(err);
assert.equal(pinnedTids[0], tid2);
assert.equal(pinnedTids[1], tid1);
socketTopics.orderPinnedTopics({uid: adminUid}, [{tid: tid1, order: 1}, {tid: tid2, order: 0}], function (err) {
socketTopics.orderPinnedTopics({ uid: adminUid }, [{ tid: tid1, order: 1 }, { tid: tid2, order: 0 }], function (err) {
assert.ifError(err);
db.getSortedSetRevRange('cid:' + topic.categoryId + ':tids:pinned', 0, -1, function (err, pinnedTids) {
assert.ifError(err);
@@ -457,7 +457,7 @@ describe('Topic\'s', function () {
uid = topic.userId;
async.waterfall([
function (done) {
topics.post({uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId }, function (err, result) {
if (err) {
return done(err);
}
@@ -561,7 +561,7 @@ describe('Topic\'s', function () {
var topicPids;
var originalBookmark = 5;
function postReply(next) {
topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid}, function (err, result) {
topics.reply({ uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid }, function (err, result) {
assert.equal(err, null, 'was created with error');
assert.ok(result);
replies.push(result);
@@ -576,7 +576,7 @@ describe('Topic\'s', function () {
groups.join('administrators', topic.userId, next);
},
function (next) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) {
assert.ifError(err);
newTopic = result.topicData;
next();
@@ -671,7 +671,7 @@ describe('Topic\'s', function () {
var socketTopics = require('../src/socket.io/topics');
var tid;
before(function (done) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
topics.post({ uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId }, function (err, result) {
assert.ifError(err);
tid = result.topicData.tid;
done();
@@ -679,14 +679,14 @@ describe('Topic\'s', function () {
});
it('should error with invalid data', function (done) {
socketTopics.loadMore({uid: adminUid}, {}, function (err) {
socketTopics.loadMore({ uid: adminUid }, {}, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should infinite load topic posts', function (done) {
socketTopics.loadMore({uid: adminUid}, {tid: tid, after: 0}, function (err, data) {
socketTopics.loadMore({ uid: adminUid }, { tid: tid, after: 0 }, function (err, data) {
assert.ifError(err);
assert(data.mainPost);
assert(data.posts);
@@ -696,16 +696,16 @@ describe('Topic\'s', function () {
});
it('should error with invalid data', function (done) {
socketTopics.loadMoreUnreadTopics({uid: adminUid}, {after: 'invalid'}, function (err) {
socketTopics.loadMoreUnreadTopics({ uid: adminUid }, { after: 'invalid' }, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should load more unread topics', function (done) {
socketTopics.markUnread({uid: adminUid}, tid, function (err) {
socketTopics.markUnread({ uid: adminUid }, tid, function (err) {
assert.ifError(err);
socketTopics.loadMoreUnreadTopics({uid: adminUid}, {cid: topic.categoryId, after: 0}, function (err, data) {
socketTopics.loadMoreUnreadTopics({ uid: adminUid }, { cid: topic.categoryId, after: 0 }, function (err, data) {
assert.ifError(err);
assert(data);
assert(Array.isArray(data.topics));
@@ -715,7 +715,7 @@ describe('Topic\'s', function () {
});
it('should error with invalid data', function (done) {
socketTopics.loadMoreRecentTopics({uid: adminUid}, {after: 'invalid'}, function (err) {
socketTopics.loadMoreRecentTopics({ uid: adminUid }, { after: 'invalid' }, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
@@ -723,7 +723,7 @@ describe('Topic\'s', function () {
it('should load more recent topics', function (done) {
socketTopics.loadMoreRecentTopics({uid: adminUid}, {cid: topic.categoryId, after: 0}, function (err, data) {
socketTopics.loadMoreRecentTopics({ uid: adminUid }, { cid: topic.categoryId, after: 0 }, function (err, data) {
assert.ifError(err);
assert(data);
assert(Array.isArray(data.topics));
@@ -732,14 +732,14 @@ describe('Topic\'s', function () {
});
it('should error with invalid data', function (done) {
socketTopics.loadMoreFromSet({uid: adminUid}, {after: 'invalid'}, function (err) {
socketTopics.loadMoreFromSet({ uid: adminUid }, { after: 'invalid' }, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should load more from custom set', function (done) {
socketTopics.loadMoreFromSet({uid: adminUid}, {set: 'uid:' + adminUid + ':topics', after: 0}, function (err, data) {
socketTopics.loadMoreFromSet({ uid: adminUid }, { set: 'uid:' + adminUid + ':topics', after: 0 }, function (err, data) {
assert.ifError(err);
assert(data);
assert(Array.isArray(data.topics));
@@ -754,10 +754,10 @@ describe('Topic\'s', function () {
before(function (done) {
async.parallel({
topic1: function (next) {
topics.post({uid: adminUid, tags: ['nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId}, next);
topics.post({ uid: adminUid, tags: ['nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId }, next);
},
topic2: function (next) {
topics.post({uid: adminUid, tags: ['nodebb'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId}, next);
topics.post({ uid: adminUid, tags: ['nodebb'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId }, next);
},
}, function (err, results) {
assert.ifError(err);
@@ -784,10 +784,10 @@ describe('Topic\'s', function () {
before(function (done) {
async.parallel({
topic: function (next) {
topics.post({uid: topic.userId, title: 'unread topic', content: 'unread topic content', cid: topic.categoryId}, next);
topics.post({ uid: topic.userId, title: 'unread topic', content: 'unread topic content', cid: topic.categoryId }, next);
},
user: function (next) {
User.create({username: 'regularJoe'}, next);
User.create({ username: 'regularJoe' }, next);
},
}, function (err, results) {
assert.ifError(err);
@@ -799,21 +799,21 @@ describe('Topic\'s', function () {
});
it('should fail with invalid data', function (done) {
socketTopics.markUnread({uid: adminUid}, null, function (err) {
socketTopics.markUnread({ uid: adminUid }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should fail if topic does not exist', function (done) {
socketTopics.markUnread({uid: adminUid}, 1231082, function (err) {
socketTopics.markUnread({ uid: adminUid }, 1231082, function (err) {
assert.equal(err.message, '[[error:no-topic]]');
done();
});
});
it('should mark topic unread', function (done) {
socketTopics.markUnread({uid: adminUid}, tid, function (err) {
socketTopics.markUnread({ uid: adminUid }, tid, function (err) {
assert.ifError(err);
topics.hasReadTopic(tid, adminUid, function (err, hasRead) {
assert.ifError(err);
@@ -825,7 +825,7 @@ describe('Topic\'s', function () {
it('should fail with invalid data', function (done) {
socketTopics.markAsRead({uid: 0}, null, function (err) {
socketTopics.markAsRead({ uid: 0 }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
@@ -833,7 +833,7 @@ describe('Topic\'s', function () {
it('should mark topic read', function (done) {
socketTopics.markAsRead({uid: adminUid}, [tid], function (err) {
socketTopics.markAsRead({ uid: adminUid }, [tid], function (err) {
assert.ifError(err);
topics.hasReadTopic(tid, adminUid, function (err, hasRead) {
assert.ifError(err);
@@ -844,7 +844,7 @@ describe('Topic\'s', function () {
});
it('should fail with invalid data', function (done) {
socketTopics.markTopicNotificationsRead({uid: 0}, null, function (err) {
socketTopics.markTopicNotificationsRead({ uid: 0 }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
@@ -855,10 +855,10 @@ describe('Topic\'s', function () {
async.waterfall([
function (next) {
socketTopics.follow({uid: adminUid}, tid, next);
socketTopics.follow({ uid: adminUid }, tid, next);
},
function (next) {
socketPosts.reply({uid: uid}, {content: 'some content', tid: tid}, next);
socketPosts.reply({ uid: uid }, { content: 'some content', tid: tid }, next);
},
function (data, next) {
setTimeout(next, 2500);
@@ -868,7 +868,7 @@ describe('Topic\'s', function () {
},
function (count, next) {
assert.equal(count, 1);
socketTopics.markTopicNotificationsRead({uid: adminUid}, [tid], next);
socketTopics.markTopicNotificationsRead({ uid: adminUid }, [tid], next);
},
function (next) {
User.notifications.getUnreadCount(adminUid, next);
@@ -884,16 +884,16 @@ describe('Topic\'s', function () {
});
it('should fail with invalid data', function (done) {
socketTopics.markAllRead({uid: 0}, null, function (err) {
socketTopics.markAllRead({ uid: 0 }, null, function (err) {
assert.equal(err.message, '[[error:invalid-uid]]');
done();
});
});
it('should mark all read', function (done) {
socketTopics.markUnread({uid: adminUid}, tid, function (err) {
socketTopics.markUnread({ uid: adminUid }, tid, function (err) {
assert.ifError(err);
socketTopics.markAllRead({uid: adminUid}, {}, function (err) {
socketTopics.markAllRead({ uid: adminUid }, {}, function (err) {
assert.ifError(err);
topics.hasReadTopic(tid, adminUid, function (err, hasRead) {
assert.ifError(err);
@@ -905,9 +905,9 @@ describe('Topic\'s', function () {
});
it('should mark all read', function (done) {
socketTopics.markUnread({uid: adminUid}, tid, function (err) {
socketTopics.markUnread({ uid: adminUid }, tid, function (err) {
assert.ifError(err);
socketTopics.markCategoryTopicsRead({uid: adminUid}, topic.categoryId, function (err) {
socketTopics.markCategoryTopicsRead({ uid: adminUid }, topic.categoryId, function (err) {
assert.ifError(err);
topics.hasReadTopic(tid, adminUid, function (err, hasRead) {
assert.ifError(err);
@@ -920,35 +920,35 @@ describe('Topic\'s', function () {
it('should fail with invalid data', function (done) {
socketTopics.markAsUnreadForAll({uid: adminUid}, null, function (err) {
socketTopics.markAsUnreadForAll({ uid: adminUid }, null, function (err) {
assert.equal(err.message, '[[error:invalid-tid]]');
done();
});
});
it('should fail with invalid data', function (done) {
socketTopics.markAsUnreadForAll({uid: 0}, [tid], function (err) {
socketTopics.markAsUnreadForAll({ uid: 0 }, [tid], function (err) {
assert.equal(err.message, '[[error:no-privileges]]');
done();
});
});
it('should fail if user is not admin', function (done) {
socketTopics.markAsUnreadForAll({uid: uid}, [tid], function (err) {
socketTopics.markAsUnreadForAll({ uid: uid }, [tid], function (err) {
assert.equal(err.message, '[[error:no-privileges]]');
done();
});
});
it('should fail if topic does not exist', function (done) {
socketTopics.markAsUnreadForAll({uid: uid}, [12312313], function (err) {
socketTopics.markAsUnreadForAll({ uid: uid }, [12312313], function (err) {
assert.equal(err.message, '[[error:no-topic]]');
done();
});
});
it('should mark topic unread for everyone', function (done) {
socketTopics.markAsUnreadForAll({uid: adminUid}, [tid], function (err) {
socketTopics.markAsUnreadForAll({ uid: adminUid }, [tid], function (err) {
assert.ifError(err);
async.parallel({
adminRead: function (next) {
@@ -974,10 +974,10 @@ describe('Topic\'s', function () {
before(function (done) {
async.parallel({
topic1: function (next) {
topics.post({uid: adminUid, tags: ['php', 'nosql', 'psql', 'nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId}, next);
topics.post({ uid: adminUid, tags: ['php', 'nosql', 'psql', 'nodebb'], title: 'topic title 1', content: 'topic 1 content', cid: topic.categoryId }, next);
},
topic2: function (next) {
topics.post({uid: adminUid, tags: ['javascript', 'mysql', 'python', 'nodejs'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId}, next);
topics.post({ uid: adminUid, tags: ['javascript', 'mysql', 'python', 'nodejs'], title: 'topic title 2', content: 'topic 2 content', cid: topic.categoryId }, next);
},
}, function (err) {
assert.ifError(err);
@@ -986,7 +986,7 @@ describe('Topic\'s', function () {
});
it('should return empty array if query is falsy', function (done) {
socketTopics.autocompleteTags({uid: adminUid}, {query: ''}, function (err, data) {
socketTopics.autocompleteTags({ uid: adminUid }, { query: '' }, function (err, data) {
assert.ifError(err);
assert.deepEqual([], data);
done();
@@ -994,7 +994,7 @@ describe('Topic\'s', function () {
});
it('should autocomplete tags', function (done) {
socketTopics.autocompleteTags({uid: adminUid}, {query: 'p'}, function (err, data) {
socketTopics.autocompleteTags({ uid: adminUid }, { query: 'p' }, function (err, data) {
assert.ifError(err);
['php', 'psql', 'python'].forEach(function (tag) {
assert.notEqual(data.indexOf(tag), -1);
@@ -1004,7 +1004,7 @@ describe('Topic\'s', function () {
});
it('should return empty array if query is falsy', function (done) {
socketTopics.searchTags({uid: adminUid}, {query: ''}, function (err, data) {
socketTopics.searchTags({ uid: adminUid }, { query: '' }, function (err, data) {
assert.ifError(err);
assert.deepEqual([], data);
done();
@@ -1012,7 +1012,7 @@ describe('Topic\'s', function () {
});
it('should search tags', function (done) {
socketTopics.searchTags({uid: adminUid}, {query: 'no'}, function (err, data) {
socketTopics.searchTags({ uid: adminUid }, { query: 'no' }, function (err, data) {
assert.ifError(err);
['nodebb', 'nodejs', 'nosql'].forEach(function (tag) {
assert.notEqual(data.indexOf(tag), -1);
@@ -1022,7 +1022,7 @@ describe('Topic\'s', function () {
});
it('should return empty array if query is falsy', function (done) {
socketTopics.searchAndLoadTags({uid: adminUid}, {query: ''}, function (err, data) {
socketTopics.searchAndLoadTags({ uid: adminUid }, { query: '' }, function (err, data) {
assert.ifError(err);
assert.equal(data.matchCount, 0);
assert.equal(data.pageCount, 1);
@@ -1032,7 +1032,7 @@ describe('Topic\'s', function () {
});
it('should search and load tags', function (done) {
socketTopics.searchAndLoadTags({uid: adminUid}, {query: 'no'}, function (err, data) {
socketTopics.searchAndLoadTags({ uid: adminUid }, { query: 'no' }, function (err, data) {
assert.ifError(err);
assert.equal(data.matchCount, 3);
assert.equal(data.pageCount, 1);
@@ -1048,14 +1048,14 @@ describe('Topic\'s', function () {
});
it('should return error if data is invalid', function (done) {
socketTopics.loadMoreTags({uid: adminUid}, {after: 'asd'}, function (err) {
socketTopics.loadMoreTags({ uid: adminUid }, { after: 'asd' }, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should load more tags', function (done) {
socketTopics.loadMoreTags({uid: adminUid}, {after: 0}, function (err, data) {
socketTopics.loadMoreTags({ uid: adminUid }, { after: 0 }, function (err, data) {
assert.ifError(err);
assert(Array.isArray(data.tags));
assert.equal(data.nextStart, 100);
@@ -1064,28 +1064,28 @@ describe('Topic\'s', function () {
});
it('should error if data is invalid', function (done) {
socketAdmin.tags.create({uid: adminUid}, null, function (err) {
socketAdmin.tags.create({ uid: adminUid }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should error if tag is invalid', function (done) {
socketAdmin.tags.create({uid: adminUid}, {tag: ''}, function (err) {
socketAdmin.tags.create({ uid: adminUid }, { tag: '' }, function (err) {
assert.equal(err.message, '[[error:invalid-tag]]');
done();
});
});
it('should error if tag is too short', function (done) {
socketAdmin.tags.create({uid: adminUid}, {tag: 'as'}, function (err) {
socketAdmin.tags.create({ uid: adminUid }, { tag: 'as' }, function (err) {
assert.equal(err.message, '[[error:tag-too-short]]');
done();
});
});
it('should create empty tag', function (done) {
socketAdmin.tags.create({uid: adminUid}, {tag: 'emptytag'}, function (err) {
socketAdmin.tags.create({ uid: adminUid }, { tag: 'emptytag' }, function (err) {
assert.ifError(err);
db.sortedSetScore('tags:topic:count', 'emptytag', function (err, score) {
assert.ifError(err);
@@ -1096,7 +1096,7 @@ describe('Topic\'s', function () {
});
it('should do nothing if tag exists', function (done) {
socketAdmin.tags.create({uid: adminUid}, {tag: 'emptytag'}, function (err) {
socketAdmin.tags.create({ uid: adminUid }, { tag: 'emptytag' }, function (err) {
assert.ifError(err);
db.sortedSetScore('tags:topic:count', 'emptytag', function (err, score) {
assert.ifError(err);
@@ -1107,14 +1107,14 @@ describe('Topic\'s', function () {
});
it('should error if data is invalid', function (done) {
socketAdmin.tags.update({uid: adminUid}, null, function (err) {
socketAdmin.tags.update({ uid: adminUid }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should error if data.tag is invalid', function (done) {
socketAdmin.tags.update({uid: adminUid}, {
socketAdmin.tags.update({ uid: adminUid }, {
bgColor: '#ff0000',
color: '#00ff00',
}, function (err) {
@@ -1124,7 +1124,7 @@ describe('Topic\'s', function () {
});
it('should update tag', function (done) {
socketAdmin.tags.update({uid: adminUid}, {
socketAdmin.tags.update({ uid: adminUid }, {
tag: 'emptytag',
bgColor: '#ff0000',
color: '#00ff00',
@@ -1143,7 +1143,7 @@ describe('Topic\'s', function () {
var meta = require('../src/meta');
meta.config.maximumRelatedTopics = 2;
var topicData = {
tags: [{value: 'javascript'}],
tags: [{ value: 'javascript' }],
};
topics.getRelatedTopics(topicData, 0, function (err, data) {
assert.ifError(err);
@@ -1155,23 +1155,23 @@ describe('Topic\'s', function () {
});
it('should return error with invalid data', function (done) {
socketAdmin.tags.deleteTags({uid: adminUid}, null, function (err) {
socketAdmin.tags.deleteTags({ uid: adminUid }, null, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should do nothing if arrays is empty', function (done) {
socketAdmin.tags.deleteTags({uid: adminUid}, {tags: []}, function (err) {
socketAdmin.tags.deleteTags({ uid: adminUid }, { tags: [] }, function (err) {
assert.ifError(err);
done();
});
});
it('should delete tags', function (done) {
socketAdmin.tags.create({uid: adminUid}, {tag: 'emptytag2'}, function (err) {
socketAdmin.tags.create({ uid: adminUid }, { tag: 'emptytag2' }, function (err) {
assert.ifError(err);
socketAdmin.tags.deleteTags({uid: adminUid}, {tags: ['emptytag', 'emptytag2', 'nodebb', 'nodejs']}, function (err) {
socketAdmin.tags.deleteTags({ uid: adminUid }, { tags: ['emptytag', 'emptytag2', 'nodebb', 'nodejs'] }, function (err) {
assert.ifError(err);
db.getObjects(['tag:emptytag', 'tag:emptytag2'], function (err, data) {
assert.ifError(err);
@@ -1200,12 +1200,12 @@ describe('Topic\'s', function () {
var tid;
var followerUid;
before(function (done) {
User.create({username: 'follower'}, function (err, uid) {
User.create({ username: 'follower' }, function (err, uid) {
if (err) {
return done(err);
}
followerUid = uid;
topics.post({uid: adminUid, title: 'topic title', content: 'some content', cid: topic.categoryId}, function (err, result) {
topics.post({ uid: adminUid, title: 'topic title', content: 'some content', cid: topic.categoryId }, function (err, result) {
if (err) {
return done(err);
}
@@ -1216,7 +1216,7 @@ describe('Topic\'s', function () {
});
it('should filter ignoring uids', function (done) {
socketTopics.changeWatching({uid: followerUid}, {tid: tid, type: 'ignore'}, function (err) {
socketTopics.changeWatching({ uid: followerUid }, { tid: tid, type: 'ignore' }, function (err) {
assert.ifError(err);
topics.filterIgnoringUids(tid, [adminUid, followerUid], function (err, uids) {
assert.ifError(err);
@@ -1228,14 +1228,14 @@ describe('Topic\'s', function () {
});
it('should error with invalid data', function (done) {
socketTopics.changeWatching({uid: followerUid}, {}, function (err) {
socketTopics.changeWatching({ uid: followerUid }, {}, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
it('should error with invalid type', function (done) {
socketTopics.changeWatching({uid: followerUid}, {tid: tid, type: 'derp'}, function (err) {
socketTopics.changeWatching({ uid: followerUid }, { tid: tid, type: 'derp' }, function (err) {
assert.equal(err.message, '[[error:invalid-command]]');
done();
});