From f9f716012b062c3d196e7b731b03b4169bdaf0fe Mon Sep 17 00:00:00 2001 From: Accalia de Elementia Date: Fri, 16 Sep 2016 14:20:02 +0000 Subject: [PATCH] feat(categories): Update topic creation to accomodate slight change to external API --- providers/nodebb/category.js | 4 ++-- test/providers/nodebb/categoryTest.js | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/providers/nodebb/category.js b/providers/nodebb/category.js index 8bf4f820..3b9a4570 100644 --- a/providers/nodebb/category.js +++ b/providers/nodebb/category.js @@ -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) diff --git a/test/providers/nodebb/categoryTest.js b/test/providers/nodebb/categoryTest.js index ddf8822c..4be2d828 100644 --- a/test/providers/nodebb/categoryTest.js +++ b/test/providers/nodebb/categoryTest.js @@ -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;