Skip to content

Commit

Permalink
Merge pull request #361 from SockDrawer/fix-categories
Browse files Browse the repository at this point in the history
feat(categories): Update topic creation to accomodate slight change t…
  • Loading branch information
yamikuronue authored Sep 16, 2016
2 parents a8240ff + f090d91 commit 20684ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions providers/nodebb/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ exports.bindCategory = function bindCategory(forum) {
*/
addTopic(title, body) {
const payload = {
'category_id': this.id,
cid: this.id,
title: title,
content: body,
tags: [],
'topic_thumb': ''
thumb: ''
};

return forum._emit('topics.post', payload)
Expand Down
21 changes: 18 additions & 3 deletions test/providers/nodebb/categoryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,32 @@ describe('providers/nodebb/categor', () => {
return category.url().should.become(expected);
});
});

describe('addTopic()', () => {
let category;
let category, cid;
beforeEach(() => {
category = new Category({});
cid = Math.random();
category = new Category({
cid: cid
});
});
it('should emit `topics.post`', () => {
return category.addTopic('title', 'body').then(() => {
forum._emit.should.have.been.calledWith('topics.post').once;
});
});
it('should emit expected body', () => {
return category.addTopic('title', 'body').then(() => {
const body = forum._emit.firstCall.args[1];
body.should.eql({
cid: cid,
title: 'title',
content: 'body',
tags: [],
thumb: ''
});
});
});
});
describe('getAllTopics()', () => {
let category, data, spy;
Expand Down

0 comments on commit 20684ce

Please sign in to comment.