mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 08:21:07 +00:00
Merge branch 'api-v3-groups' of github.com:HabitRPG/habitrpg into api-v3-groups
This commit is contained in:
commit
831c8c4165
1 changed files with 48 additions and 13 deletions
|
|
@ -1,15 +1,15 @@
|
|||
import {
|
||||
createAndPopulateGroup,
|
||||
generateUser,
|
||||
generateGroup,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('GET /groups/:groupId/chat', () => {
|
||||
describe.only('GET /groups/:groupId/chat', () => {
|
||||
let user, api;
|
||||
|
||||
before(() => {
|
||||
return generateUser({balance: 2}).then((generatedUser) => {
|
||||
return generateUser().then((generatedUser) => {
|
||||
user = generatedUser;
|
||||
api = requester(user);
|
||||
});
|
||||
|
|
@ -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) => {
|
||||
return generateGroup(generatedLeader, {
|
||||
name: 'test group',
|
||||
type: 'guild',
|
||||
privacy: 'public',
|
||||
}, {
|
||||
chat: [
|
||||
'Hello',
|
||||
'Welcome to the Guild',
|
||||
],
|
||||
});
|
||||
})
|
||||
.then((createdGroup) => {
|
||||
group = createdGroup;
|
||||
|
|
@ -40,7 +43,39 @@ 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 generateUser({balance: 2})
|
||||
.then((generatedLeader) => {
|
||||
return generateGroup(generatedLeader, {
|
||||
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'),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue