From 67da5a977aed2a1c6996faf58867a11c3aa07ea7 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 21 Dec 2015 17:33:16 -0500 Subject: [PATCH] test(chat): user not member of group Currently failing because group is not getting defined correctly? --- test/api/v3/integration/chat/GET-chat.test.js | 54 +++++++++++++++---- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/test/api/v3/integration/chat/GET-chat.test.js b/test/api/v3/integration/chat/GET-chat.test.js index 206eac6f75..265b80da54 100644 --- a/test/api/v3/integration/chat/GET-chat.test.js +++ b/test/api/v3/integration/chat/GET-chat.test.js @@ -1,8 +1,8 @@ import { - createAndPopulateGroup, generateUser, generateGroup, requester, + translate as t, } from '../../../../helpers/api-integration.helper'; describe('GET /groups/:groupId/chat', () => { @@ -19,15 +19,18 @@ describe('GET /groups/:groupId/chat', () => { let group; before(() => { - return generateGroup(user, { - name: 'test group', - type: 'guild', - privacy: 'public', - }, { - chat: [ - 'Hello', - 'Welcome to the Guild', - ], + return generateUser({balance: 2}) + .then((generatedLeader) => { + generateGroup(generatedLeader, { + name: 'test group', + type: 'guild', + privacy: 'public', + }, { + chat: [ + 'Hello', + 'Welcome to the Guild', + ], + }); }) .then((createdGroup) => { group = createdGroup; @@ -40,7 +43,36 @@ describe('GET /groups/:groupId/chat', () => { expect(getChat).to.eql(group.chat); }); }); + }); - // TODO tests that you can only access your groups' chat + context('private Guild', () => { + let group; + + before(() => { + return generateGroup(user, { + name: 'test group', + type: 'guild', + privacy: 'private', + }, { + chat: [ + 'Hello', + 'Welcome to the Guild', + ], + }) + .then((createdGroup) => { + group = createdGroup; + }); + }); + + it('returns error if user is not member of requested private group', () => { + return expect( + api.get('/groups/' + group._id + '/chat') + ) + .to.eventually.be.rejected.and.eql({ + code: 404, + error: 'NotFound', + message: t('groupNotFound'), + }); + }); }); });