From 0a245a886853bd3eb33ffc55975ececcea05d252 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 21 Nov 2016 15:44:58 +0300 Subject: [PATCH] tag controller test --- test/controllers.js | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/controllers.js b/test/controllers.js index 2ec3c896ce..6841fa3821 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -615,6 +615,55 @@ describe('Controllers', function () { }); }); + describe('tags', function () { + var tid; + before(function (done) { + topics.post({ + uid: fooUid, + title: 'topic title', + content: 'test topic content', + cid: cid, + tags: ['nodebb', 'bug', 'test'] + }, function (err, result) { + assert.ifError(err); + tid = result.topicData.tid; + done(); + }); + }); + + it('should render tags page', function (done) { + request(nconf.get('url') + '/api/tags', {json: true}, function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + assert(Array.isArray(body.tags)); + done(); + }); + }); + + it('should render tag page with no topics', function (done) { + request(nconf.get('url') + '/api/tags/notag', {json: true}, function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + assert(Array.isArray(body.topics)); + assert.equal(body.topics.length, 0); + done(); + }); + }); + + it('should render tag page with 1 topic', function (done) { + request(nconf.get('url') + '/api/tags/nodebb', {json: true}, function (err, res, body) { + assert.ifError(err); + assert.equal(res.statusCode, 200); + assert(body); + assert(Array.isArray(body.topics)); + assert.equal(body.topics.length, 1); + done(); + }); + }); + }); + after(function (done) { var analytics = require('../src/analytics');