From c80f406b2111f3f819669acc2355ee9a97a78cb1 Mon Sep 17 00:00:00 2001 From: gaba Date: Fri, 10 Feb 2017 11:51:34 -0800 Subject: [PATCH] Add tests --- test/services/comments.js | 41 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/services/comments.js b/test/services/comments.js index fc2105cb1..82ceb1b61 100644 --- a/test/services/comments.js +++ b/test/services/comments.js @@ -70,11 +70,14 @@ describe('services.CommentsService', () => { const users = [{ email: 'stampi@gmail.com', displayName: 'Stampi', - password: '1Coral!!' + password: '1Coral!!', + roles: ['ADMIN'], + _id: '1' }, { email: 'sockmonster@gmail.com', displayName: 'Sockmonster', - password: '2Coral!!' + password: '2Coral!!', + _id : '2' }]; const actions = [{ @@ -256,4 +259,38 @@ describe('services.CommentsService', () => { }); }); + + describe('#tagByStaff()', () => { + + it('creates a new comment by admin', () => { + return UsersService.findLocalUser('stampi@gmail.com', '1Coral!!').then((user) => { + return UsersService.addRoleToUser(user.id, 'ADMIN').then(() => { + return CommentsService + .publicCreate({ + body: 'This is a comment!', + status: 'ACCEPTED', + author_id: user.id + }).then((c) => { + expect(c).to.not.be.null; + expect(c.tags).to.not.have.length(0); + expect(c.tags[0].name).to.be.equal('STAFF'); + }); + }); + }); + }); + + it('creates a new comment by non admin', () => { + return UsersService.findLocalUser('sockmonster@gmail.com', '2Coral!!').then((user) => { + return CommentsService + .publicCreate({ + body: 'This is a comment!', + status: 'ACCEPTED', + author_id: user.id + }).then((c) => { + expect(c).to.not.be.null; + expect(c.tags).to.have.length(0); + }); + }); + }); + }); });