test(chat): user not member of group

Currently failing because group is not getting defined correctly?
This commit is contained in:
Sabe Jones
2015-12-21 17:33:16 -05:00
parent 99be74b6f7
commit 67da5a977a

View File

@@ -1,8 +1,8 @@
import { import {
createAndPopulateGroup,
generateUser, generateUser,
generateGroup, generateGroup,
requester, requester,
translate as t,
} from '../../../../helpers/api-integration.helper'; } from '../../../../helpers/api-integration.helper';
describe('GET /groups/:groupId/chat', () => { describe('GET /groups/:groupId/chat', () => {
@@ -19,15 +19,18 @@ describe('GET /groups/:groupId/chat', () => {
let group; let group;
before(() => { before(() => {
return generateGroup(user, { return generateUser({balance: 2})
name: 'test group', .then((generatedLeader) => {
type: 'guild', generateGroup(generatedLeader, {
privacy: 'public', name: 'test group',
}, { type: 'guild',
chat: [ privacy: 'public',
'Hello', }, {
'Welcome to the Guild', chat: [
], 'Hello',
'Welcome to the Guild',
],
});
}) })
.then((createdGroup) => { .then((createdGroup) => {
group = createdGroup; group = createdGroup;
@@ -40,7 +43,36 @@ describe('GET /groups/:groupId/chat', () => {
expect(getChat).to.eql(group.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'),
});
});
}); });
}); });