Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/topics/recent.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function (Topics) {
year: 31104000000,
};

Topics.getRecentTopics = async function (cid, uid, start, stop, filter) {
Topics.getRecentTopics = async function ({cid, uid, start, stop, filter}) {
return await Topics.getSortedTopics({
cids: cid,
uid: uid,
Expand Down
33 changes: 33 additions & 0 deletions test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,39 @@ describe('Topic\'s', () => {
});
});

describe('recent topics', () => {
let category;
before(async () => {
category = await categories.create({ name: 'recent' });
// create a couple topics
await topics.post({
uid: topic.userId,
cid: category.cid,
title: 'first recent topic',
content: 'topic 1 OP',
});
await topics.post({
uid: topic.userId,
cid: category.cid,
title: 'second recent topic',
content: 'topic 2 OP',
});
});

it('should get topics ordered by most recent first', async () => {
const data = await topics.getRecentTopics({
cids: [category.cid],
uid: topic.userId,
start: 0,
stop: -1,
});
assert(data);
assert(Array.isArray(data.topics));
assert.strictEqual(data.topics[0].title, 'second recent topic');
assert.strictEqual(data.topics[1].title, 'first recent topic');
});
});

describe('scheduled topics', () => {
let categoryObj;
let topicData;
Expand Down